Revision: 21195
Author:   [email protected]
Date:     Thu May  8 06:52:35 2014 UTC
Log:      Unbreak samples and tools.

Removed a related TODO in d8.cc on the way.

BUG=v8::3318
LOG=y
[email protected]

Review URL: https://codereview.chromium.org/275463002
http://code.google.com/p/v8/source/detail?r=21195

Modified:
 /branches/bleeding_edge/samples/lineprocessor.cc
 /branches/bleeding_edge/samples/process.cc
 /branches/bleeding_edge/samples/shell.cc
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/tools/lexer-shell.cc
 /branches/bleeding_edge/tools/parser-shell.cc

=======================================
--- /branches/bleeding_edge/samples/lineprocessor.cc Fri Apr 25 11:00:37 2014 UTC +++ /branches/bleeding_edge/samples/lineprocessor.cc Thu May 8 06:52:35 2014 UTC
@@ -133,7 +133,9 @@

 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<v8::String> script_source;
@@ -212,8 +214,6 @@

   debug_message_context.Reset(isolate, context);

-  v8::Locker locker(isolate);
-
   if (support_callback) {
     v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true);
   }
=======================================
--- /branches/bleeding_edge/samples/process.cc  Tue Apr 22 10:45:43 2014 UTC
+++ /branches/bleeding_edge/samples/process.cc  Thu May  8 06:52:35 2014 UTC
@@ -651,7 +651,8 @@
     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<String> source = ReadFile(isolate, file);
   if (source.IsEmpty()) {
=======================================
--- /branches/bleeding_edge/samples/shell.cc    Tue Apr 22 10:45:43 2014 UTC
+++ /branches/bleeding_edge/samples/shell.cc    Thu May  8 06:52:35 2014 UTC
@@ -65,23 +65,35 @@
 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<v8::Context> 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;
=======================================
--- /branches/bleeding_edge/src/d8.cc   Tue May  6 13:06:12 2014 UTC
+++ /branches/bleeding_edge/src/d8.cc   Thu May  8 06:52:35 2014 UTC
@@ -1612,20 +1612,10 @@
 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
  public:
   virtual void* Allocate(size_t length) {
-    void* result = malloc(length);
-    memset(result, 0, length);
-    return result;
+    return memset(AllocateUninitialized(length), 0, length);
   }
-  virtual void* AllocateUninitialized(size_t length) {
-    return malloc(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
-  }
 };


=======================================
--- /branches/bleeding_edge/tools/lexer-shell.cc Tue Apr 22 10:45:43 2014 UTC +++ /branches/bleeding_edge/tools/lexer-shell.cc Thu May 8 06:52:35 2014 UTC
@@ -206,19 +206,20 @@
       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<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); v8::Local<v8::Context> 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*>(isolate), print_tokens,
                            repeat);
         baseline_total += time.InMillisecondsF();
       }
=======================================
--- /branches/bleeding_edge/tools/parser-shell.cc Tue Apr 22 10:45:43 2014 UTC +++ /branches/bleeding_edge/tools/parser-shell.cc Thu May 8 06:52:35 2014 UTC
@@ -128,8 +128,9 @@
       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<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to