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

Commit 809750d

Browse files
committed
Instrument callback bridge with TRACEINST()
1 parent dedf7af commit 809750d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

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

@@ -29,6 +31,7 @@ union Sass_Value* sass_custom_function(const union Sass_Value* s_args, Sass_Func
2931
argv.push_back((void*)sass_list_get_value(s_args, i));
3032
}
3133

34+
TRACEINST(&bridge) << "Function will be executed";
3235
return bridge(argv);
3336
}
3437

@@ -120,6 +123,7 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
120123
v8::Local<v8::Function> importer = importer_callback.As<v8::Function>();
121124

122125
CustomImporterBridge *bridge = new CustomImporterBridge(importer, ctx_w->is_sync);
126+
TRACEINST(bridge) << "Importer bridge created";
123127
ctx_w->importer_bridges.push_back(bridge);
124128

125129
Sass_Importer_List c_importers = sass_make_importer_list(1);
@@ -135,6 +139,7 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
135139
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(Nan::Get(importers, static_cast<uint32_t>(i)).ToLocalChecked());
136140

137141
CustomImporterBridge *bridge = new CustomImporterBridge(callback, ctx_w->is_sync);
142+
TRACEINST(bridge) << "Importer bridge created (item #" << i << ")";
138143
ctx_w->importer_bridges.push_back(bridge);
139144

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

158163
CustomFunctionBridge *bridge = new CustomFunctionBridge(callback, ctx_w->is_sync);
164+
TRACEINST(bridge) << "Custom function bridge created (item #" << i << ")";
159165
ctx_w->function_bridges.push_back(bridge);
160166

161167
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)