Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/rtScriptV8/rtScriptV8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ extern "C" const char U_DATA_API SMALL_ICUDATA_ENTRY_POINT[];
#pragma GCC diagnostic pop
#endif

static rtAtomic sNextId = 100;

class V8ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t size)
Expand Down Expand Up @@ -202,6 +204,8 @@ class rtV8Context: rtIScriptContext // V8

int mRefCount;

rtAtomic mId;

const char *js_file;
std::string js_script;
};
Expand Down Expand Up @@ -432,9 +436,13 @@ rtV8Context::rtV8Context(Isolate *isolate, Platform *platform, uv_loop_t *loop)
Isolate::Scope isolate_scope(mIsolate);
HandleScope handle_scope(mIsolate);

mId = rtAtomicInc(&sNextId);

// Create a new context.
Local<Context> localContext = Context::New(mIsolate);

localContext->SetEmbedderData(HandleMap::kContextIdIndex, Integer::New(mIsolate, mId));

mContext.Reset(mIsolate, localContext); // local to persistent

Context::Scope contextScope(localContext);
Expand Down