From: svenpanne@chromium.org Date: Thu, 8 May 2014 06:52:35 +0000 (+0000) Subject: Unbreak samples and tools. X-Git-Tag: upstream/4.7.83~9228 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=967a79d21a36da6d19661142fb11d260757e5751;p=platform%2Fupstream%2Fv8.git Unbreak samples and tools. Removed a related TODO in d8.cc on the way. BUG=v8::3318 LOG=y R=dcarney@chromium.org Review URL: https://codereview.chromium.org/275463002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21195 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc index f259ea4..7e820b3 100644 --- a/samples/lineprocessor.cc +++ b/samples/lineprocessor.cc @@ -133,7 +133,9 @@ void DispatchDebugMessages() { int RunMain(int argc, char* argv[]) { v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::New(); + v8::Isolate::Scope isolate_scope(isolate); + v8::Locker locker(isolate); v8::HandleScope handle_scope(isolate); v8::Handle script_source; @@ -212,8 +214,6 @@ int RunMain(int argc, char* argv[]) { debug_message_context.Reset(isolate, context); - v8::Locker locker(isolate); - if (support_callback) { v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true); } diff --git a/samples/process.cc b/samples/process.cc index 37b4d39..7cfbc9e 100644 --- a/samples/process.cc +++ b/samples/process.cc @@ -651,7 +651,8 @@ int main(int argc, char* argv[]) { fprintf(stderr, "No script was specified.\n"); return 1; } - Isolate* isolate = Isolate::GetCurrent(); + Isolate* isolate = Isolate::New(); + Isolate::Scope isolate_scope(isolate); HandleScope scope(isolate); Handle source = ReadFile(isolate, file); if (source.IsEmpty()) { diff --git a/samples/shell.cc b/samples/shell.cc index f8d2c84..e9f9989 100644 --- a/samples/shell.cc +++ b/samples/shell.cc @@ -65,23 +65,35 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* handler); static bool run_shell; +class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { + public: + virtual void* Allocate(size_t length) { + return memset(AllocateUninitialized(length), 0, length); + } + virtual void* AllocateUninitialized(size_t length) { return malloc(length); } + virtual void Free(void* data, size_t) { free(data); } +}; + + int main(int argc, char* argv[]) { v8::V8::InitializeICU(); v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + ShellArrayBufferAllocator array_buffer_allocator; + v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); + v8::Isolate* isolate = v8::Isolate::New(); run_shell = (argc == 1); int result; { + v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Handle context = CreateShellContext(isolate); if (context.IsEmpty()) { fprintf(stderr, "Error creating context\n"); return 1; } - context->Enter(); + v8::Context::Scope context_scope(context); result = RunMain(isolate, argc, argv); if (run_shell) RunShell(context); - context->Exit(); } v8::V8::Dispose(); return result; diff --git a/src/d8.cc b/src/d8.cc index 396d68b..b8e4492 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -1612,20 +1612,10 @@ static void DumpHeapConstants(i::Isolate* isolate) { class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { public: virtual void* Allocate(size_t length) { - void* result = malloc(length); - memset(result, 0, length); - return result; - } - virtual void* AllocateUninitialized(size_t length) { - return malloc(length); + return memset(AllocateUninitialized(length), 0, length); } + virtual void* AllocateUninitialized(size_t length) { return malloc(length); } virtual void Free(void* data, size_t) { free(data); } - // TODO(dslomov): Remove when v8:2823 is fixed. - virtual void Free(void* data) { -#ifndef V8_SHARED - UNREACHABLE(); -#endif - } }; diff --git a/tools/lexer-shell.cc b/tools/lexer-shell.cc index 273cdd9..a85dc7d 100644 --- a/tools/lexer-shell.cc +++ b/tools/lexer-shell.cc @@ -206,19 +206,20 @@ int main(int argc, char* argv[]) { fnames.push_back(std::string(argv[i])); } } - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::New(); { + v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Handle global = v8::ObjectTemplate::New(isolate); v8::Local context = v8::Context::New(isolate, NULL, global); ASSERT(!context.IsEmpty()); { v8::Context::Scope scope(context); - Isolate* isolate = Isolate::Current(); double baseline_total = 0; for (size_t i = 0; i < fnames.size(); i++) { TimeDelta time; - time = ProcessFile(fnames[i].c_str(), encoding, isolate, print_tokens, + time = ProcessFile(fnames[i].c_str(), encoding, + reinterpret_cast(isolate), print_tokens, repeat); baseline_total += time.InMillisecondsF(); } diff --git a/tools/parser-shell.cc b/tools/parser-shell.cc index 2d95918..4acdf7c 100644 --- a/tools/parser-shell.cc +++ b/tools/parser-shell.cc @@ -128,8 +128,9 @@ int main(int argc, char* argv[]) { fnames.push_back(std::string(argv[i])); } } - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = v8::Isolate::New(); { + v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Handle global = v8::ObjectTemplate::New(isolate); v8::Local context = v8::Context::New(isolate, NULL, global);