Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit f041ec6

Browse files
committed
Instrument callback bridge with TRACEINST()
1 parent b53b7f0 commit f041ec6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/binding.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "custom_function_bridge.h"
55
#include "create_string.h"
66
#include "sass_types/factory.h"
7+
#include "debug.h"
78

89
Sass_Import_List sass_importer(const char* cur_path, Sass_Importer_Entry cb, struct Sass_Compiler* comp)
910
{
@@ -16,6 +17,7 @@ Sass_Import_List sass_importer(const char* cur_path, Sass_Importer_Entry cb, str
1617
argv.push_back((void*)cur_path);
1718
argv.push_back((void*)prev_path);
1819

20+
TRACEINST(&bridge) << "Importer will be executed";
1921
return bridge(argv);
2022
}
2123

@@ -30,6 +32,7 @@ union Sass_Value* sass_custom_function(const union Sass_Value* s_args, Sass_Func
3032
}
3133

3234
try {
35+
TRACEINST(&bridge) << "Function will be executed";
3336
return bridge(argv);
3437
}
3538
catch (const std::exception& e) {
@@ -125,6 +128,7 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
125128
v8::Local<v8::Function> importer = importer_callback.As<v8::Function>();
126129

127130
CustomImporterBridge *bridge = new CustomImporterBridge(importer, ctx_w->is_sync);
131+
TRACEINST(bridge) << "Importer bridge created";
128132
ctx_w->importer_bridges.push_back(bridge);
129133

130134
Sass_Importer_List c_importers = sass_make_importer_list(1);
@@ -140,6 +144,7 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
140144
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(Nan::Get(importers, static_cast<uint32_t>(i)).ToLocalChecked());
141145

142146
CustomImporterBridge *bridge = new CustomImporterBridge(callback, ctx_w->is_sync);
147+
TRACEINST(bridge) << "Importer bridge created (item #" << i << ")";
143148
ctx_w->importer_bridges.push_back(bridge);
144149

145150
c_importers[i] = sass_make_importer(sass_importer, importers->Length() - i - 1, bridge);
@@ -161,6 +166,7 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
161166
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(Nan::Get(functions, signature).ToLocalChecked());
162167

163168
CustomFunctionBridge *bridge = new CustomFunctionBridge(callback, ctx_w->is_sync);
169+
TRACEINST(bridge) << "Custom function bridge created (item #" << i << ")";
164170
ctx_w->function_bridges.push_back(bridge);
165171

166172
Sass_Function_Entry fn = sass_make_function(create_string(signature), sass_custom_function, bridge);

src/callback_bridge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <algorithm>
77
#include <uv.h>
88

9+
#include "debug.h"
10+
911
#define COMMA ,
1012

1113
template <typename T, typename L = void*>
@@ -86,6 +88,7 @@ CallbackBridge<T, L>::operator= (const CallbackBridge<T,L>& other)
8688
* V8 context is available.
8789
*/
8890
if (other != *this) {
91+
TRACEINST(this) << "Instance will be copied over from " << (void *)&other;
8992
delete this->callback;
9093
this->wrapper.Reset();
9194
uv_cond_destroy(&this->condition_variable);
@@ -125,6 +128,7 @@ CallbackBridge<T, L>::init_wrapper(void) {
125128

126129
template <typename T, typename L>
127130
CallbackBridge<T, L>::~CallbackBridge() {
131+
TRACEINST(this) << "Instance shuts down";
128132
delete this->callback;
129133
this->wrapper.Reset();
130134
uv_cond_destroy(&this->condition_variable);

0 commit comments

Comments
 (0)