Created
May 28, 2019 21:57
-
-
Save laverdet/586ac62ad61942fecb300fabc408c9b9 to your computer and use it in GitHub Desktop.
Leading spread failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "v8.h" | |
#include "libplatform/libplatform.h" | |
using namespace v8; | |
void GCEpilogueCallback(Isolate* isolate, GCType type, GCCallbackFlags flags) { | |
printf("gc epilogue\n"); | |
isolate->TerminateExecution(); | |
} | |
int main(int argc, char* argv[]) { | |
// Initialize V8. | |
V8::InitializeICUDefaultLocation(argv[0]); | |
V8::InitializeExternalStartupData(argv[0]); | |
auto platform = platform::NewDefaultPlatform(); | |
V8::InitializePlatform(platform.get()); | |
V8::Initialize(); | |
// Create new isolate from snapshot | |
Isolate::CreateParams create_params; | |
create_params.constraints.set_max_semi_space_size_in_kb(16 * 1024); | |
create_params.constraints.set_max_old_space_size(32); | |
std::unique_ptr<ArrayBuffer::Allocator> array_buffer_allocator{ArrayBuffer::Allocator::NewDefaultAllocator()}; | |
create_params.array_buffer_allocator = array_buffer_allocator.get(); | |
Isolate* isolate = Isolate::New(create_params); | |
isolate->AddGCEpilogueCallback(GCEpilogueCallback); | |
{ | |
Locker locker{isolate}; | |
Isolate::Scope isolate_scope{isolate}; | |
HandleScope handle_scope{isolate}; | |
Local<Context> context = Context::New(isolate); | |
Context::Scope context_scope{context}; | |
Local<String> source = String::NewFromUtf8(isolate, | |
"[...{ [Symbol.iterator]: () => ({ next: () => this }) }];", NewStringType::kNormal | |
).ToLocalChecked(); | |
Local<Script> script = Script::Compile(context, source).ToLocalChecked(); | |
Local<Value> result; | |
if (!script->Run(context).ToLocal(&result)) { | |
printf("terminated\n"); | |
} | |
} | |
isolate->Dispose(); | |
V8::Dispose(); | |
V8::ShutdownPlatform(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment