| 159 | } |
| 160 | |
| 161 | V8JavaScriptContext::V8JavaScriptContext(JavaScriptTaskScheduler* taskScheduler) : IJavaScriptContext(taskScheduler) { |
| 162 | initializeV8Engine(); |
| 163 | _allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); |
| 164 | _params.array_buffer_allocator = _allocator; |
| 165 | _isolate = v8::Isolate::New(_params); |
| 166 | |
| 167 | SC_ASSERT(_isolate->GetNumberOfDataSlots() >= 1); |
| 168 | |
| 169 | // NOTE(rjaber): An isolate is a VM instance with its own heap. |
| 170 | v8::HandleScope handleScope(_isolate); |
| 171 | auto ctx = v8::Context::New(_isolate); |
| 172 | ctx->Enter(); |
| 173 | _context.Reset(_isolate, ctx); |
| 174 | |
| 175 | auto valdiObjectTemplate = v8::ObjectTemplate::New(_isolate); |
| 176 | valdiObjectTemplate->SetInternalFieldCount(static_cast<int>(InternalFieldSlot::Count)); |
| 177 | _valdiObjectTemplate.Reset(_isolate, valdiObjectTemplate); |
| 178 | auto propertyString = v8::String::NewFromUtf8Literal(_isolate, "com.snapinc.valdi.js.v8.function.private_prop"); |
| 179 | auto functionPrivate = v8::Private::New(_isolate, propertyString); |
| 180 | _functionDataProperty.Reset(_isolate, functionPrivate); |
| 181 | } |
| 182 | |
| 183 | V8JavaScriptContext::~V8JavaScriptContext() { |
| 184 | prepareForTeardown(); |
nothing calls this directly
no test coverage detected