Revision: 18009
Author:   [email protected]
Date:     Fri Nov 22 12:35:39 2013 UTC
Log:      Remove usage of deprecated APIs from d8

Also turn on deprecation warnings

BUG=v8:3023
[email protected], [email protected]
LOG=n

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

Modified:
 /branches/bleeding_edge/src/d8-debug.cc
 /branches/bleeding_edge/src/d8-posix.cc
 /branches/bleeding_edge/src/d8-windows.cc
 /branches/bleeding_edge/src/d8.cc
 /branches/bleeding_edge/src/d8.gyp
 /branches/bleeding_edge/src/d8.h

=======================================
--- /branches/bleeding_edge/src/d8-debug.cc     Tue Oct  1 07:53:37 2013 UTC
+++ /branches/bleeding_edge/src/d8-debug.cc     Fri Nov 22 12:35:39 2013 UTC
@@ -63,7 +63,8 @@
   TryCatch try_catch;

   // Get the toJSONProtocol function on the event and get the JSON format.
-  Local<String> to_json_fun_name = String::New("toJSONProtocol");
+  Local<String> to_json_fun_name =
+      String::NewFromUtf8(isolate, "toJSONProtocol");
   Handle<Object> event_data = event_details.GetEventData();
   Local<Function> to_json_fun =
       Local<Function>::Cast(event_data->Get(to_json_fun_name));
@@ -80,7 +81,7 @@
     Shell::ReportException(isolate, &try_catch);
     return;
   }
-  String::Utf8Value str(details->Get(String::New("text")));
+ String::Utf8Value str(details->Get(String::NewFromUtf8(isolate, "text")));
   if (str.length() == 0) {
     // Empty string is used to signal not to process this event.
     return;
@@ -88,7 +89,8 @@
   printf("%s\n", *str);

   // Get the debug command processor.
-  Local<String> fun_name = String::New("debugCommandProcessor");
+  Local<String> fun_name =
+      String::NewFromUtf8(isolate, "debugCommandProcessor");
   Handle<Object> exec_state = event_details.GetExecutionState();
   Local<Function> fun = Local<Function>::Cast(exec_state->Get(fun_name));
   Local<Object> cmd_processor =
@@ -112,8 +114,8 @@
     TryCatch try_catch;

     // Convert the debugger command to a JSON debugger request.
-    Handle<Value> request =
-        Shell::DebugCommandToJSONRequest(isolate, String::New(command));
+    Handle<Value> request = Shell::DebugCommandToJSONRequest(
+        isolate, String::NewFromUtf8(isolate, command));
     if (try_catch.HasCaught()) {
       Shell::ReportException(isolate, &try_catch);
       continue;
@@ -134,7 +136,7 @@
     // Invoke the JavaScript to convert the debug command line to a JSON
// request, invoke the JSON request and convert the JSON respose to a text
     // representation.
-    fun_name = String::New("processDebugRequest");
+    fun_name = String::NewFromUtf8(isolate, "processDebugRequest");
     fun = Handle<Function>::Cast(cmd_processor->Get(fun_name));
     args[0] = request;
     Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args);
@@ -151,12 +153,14 @@
       Shell::ReportException(isolate, &try_catch);
       continue;
     }
-    String::Utf8Value text_str(response_details->Get(String::New("text")));
+    String::Utf8Value text_str(
+        response_details->Get(String::NewFromUtf8(isolate, "text")));
     if (text_str.length() > 0) {
       printf("%s\n", *text_str);
     }
-    running =
- response_details->Get(String::New("running"))->ToBoolean()->Value(); + running = response_details->Get(String::NewFromUtf8(isolate, "running"))
+                  ->ToBoolean()
+                  ->Value();
   }
 }

@@ -273,15 +277,14 @@

   // Print the event details.
   TryCatch try_catch;
-  Handle<Object> details =
-      Shell::DebugMessageDetails(isolate_,
- Handle<String>::Cast(String::New(message)));
+  Handle<Object> details = Shell::DebugMessageDetails(
+ isolate_, Handle<String>::Cast(String::NewFromUtf8(isolate_, message)));
   if (try_catch.HasCaught()) {
     Shell::ReportException(isolate_, &try_catch);
     PrintPrompt();
     return;
   }
-  String::Utf8Value str(details->Get(String::New("text")));
+ String::Utf8Value str(details->Get(String::NewFromUtf8(isolate_, "text")));
   if (str.length() == 0) {
     // Empty string is used to signal not to process this event.
     return;
@@ -292,7 +295,9 @@
     printf("???\n");
   }

- bool is_running = details->Get(String::New("running"))->ToBoolean()->Value();
+  bool is_running = details->Get(String::NewFromUtf8(isolate_, "running"))
+                        ->ToBoolean()
+                        ->Value();
   PrintPrompt(is_running);
 }

@@ -303,8 +308,8 @@

   // Convert the debugger command to a JSON debugger request.
   TryCatch try_catch;
-  Handle<Value> request =
-      Shell::DebugCommandToJSONRequest(isolate_, String::New(command));
+  Handle<Value> request = Shell::DebugCommandToJSONRequest(
+      isolate_, String::NewFromUtf8(isolate_, command));
   if (try_catch.HasCaught()) {
     Shell::ReportException(isolate_, &try_catch);
     PrintPrompt();
=======================================
--- /branches/bleeding_edge/src/d8-posix.cc     Thu Sep 26 07:37:59 2013 UTC
+++ /branches/bleeding_edge/src/d8-posix.cc     Fri Nov 22 12:35:39 2013 UTC
@@ -188,12 +188,12 @@
   ExecArgs() {
     exec_args_[0] = NULL;
   }
-  bool Init(Handle<Value> arg0, Handle<Array> command_args) {
+ bool Init(Isolate* isolate, Handle<Value> arg0, Handle<Array> command_args) {
     String::Utf8Value prog(arg0);
     if (*prog == NULL) {
       const char* message =
           "os.system(): String conversion of program name failed";
-      ThrowException(String::New(message));
+      isolate->ThrowException(String::NewFromUtf8(isolate, message));
       return false;
     }
     int len = prog.length() + 3;
@@ -208,7 +208,7 @@
         exec_args_[i] = NULL;  // Consistent state for destructor.
         const char* message =
             "os.system(): String conversion of argument failed.";
-        ThrowException(String::New(message));
+        isolate->ThrowException(String::NewFromUtf8(isolate, message));
         return false;
       }
       int len = utf8_arg.length() + 1;
@@ -245,8 +245,8 @@
     if (args[3]->IsNumber()) {
       *total_timeout = args[3]->Int32Value();
     } else {
-      args.GetIsolate()->ThrowException(
-          String::New("system: Argument 4 must be a number"));
+      args.GetIsolate()->ThrowException(String::NewFromUtf8(
+          args.GetIsolate(), "system: Argument 4 must be a number"));
       return false;
     }
   }
@@ -254,8 +254,8 @@
     if (args[2]->IsNumber()) {
       *read_timeout = args[2]->Int32Value();
     } else {
-      args.GetIsolate()->ThrowException(
-          String::New("system: Argument 3 must be a number"));
+      args.GetIsolate()->ThrowException(String::NewFromUtf8(
+          args.GetIsolate(), "system: Argument 3 must be a number"));
       return false;
     }
   }
@@ -293,14 +293,14 @@

// Runs in the parent process. Checks that the child was able to exec (closing
 // the file desriptor), or reports an error if it failed.
-static bool ChildLaunchedOK(int* exec_error_fds) {
+static bool ChildLaunchedOK(Isolate* isolate, int* exec_error_fds) {
   int bytes_read;
   int err;
   do {
     bytes_read = read(exec_error_fds[kReadFD], &err, sizeof(err));
   } while (bytes_read == -1 && errno == EINTR);
   if (bytes_read != 0) {
-    ThrowException(String::New(strerror(err)));
+    isolate->ThrowException(String::NewFromUtf8(isolate, strerror(err)));
     return false;
   }
   return true;
@@ -309,7 +309,8 @@

// Accumulates the output from the child in a string handle. Returns true if it
 // succeeded or false if an exception was thrown.
-static Handle<Value> GetStdout(int child_fd,
+static Handle<Value> GetStdout(Isolate* isolate,
+                               int child_fd,
                                struct timeval& start_time,
                                int read_timeout,
                                int total_timeout) {
@@ -320,7 +321,8 @@
   char buffer[kStdoutReadBufferSize];

   if (fcntl(child_fd, F_SETFL, O_NONBLOCK) != 0) {
-    return ThrowException(String::New(strerror(errno)));
+    return isolate->ThrowException(
+        String::NewFromUtf8(isolate, strerror(errno)));
   }

   int bytes_read;
@@ -335,7 +337,8 @@
                       total_timeout,
                       start_time) ||
             (TimeIsOut(start_time, total_timeout))) {
- return ThrowException(String::New("Timed out waiting for output"));
+          return isolate->ThrowException(
+ String::NewFromUtf8(isolate, "Timed out waiting for output"));
         }
         continue;
       } else if (errno == EINTR) {
@@ -348,7 +351,8 @@
       int length = bytes_read == 0 ?
                    bytes_read + fullness :
LengthWithoutIncompleteUtf8(buffer, bytes_read + fullness);
-      Handle<String> addition = String::New(buffer, length);
+      Handle<String> addition =
+ String::NewFromUtf8(isolate, buffer, String::kNormalString, length);
       accumulator = String::Concat(accumulator, addition);
       fullness = bytes_read + fullness - length;
       memcpy(buffer, buffer + length, fullness);
@@ -377,7 +381,8 @@


 // Get exit status of child.
-static bool WaitForChild(int pid,
+static bool WaitForChild(Isolate* isolate,
+                         int pid,
                          ZombieProtector& child_waiter,
                          struct timeval& start_time,
                          int read_timeout,
@@ -394,7 +399,8 @@
     if (useconds < 1000000) useconds <<= 1;
     if ((read_timeout != -1 && useconds / 1000 > read_timeout) ||
         (TimeIsOut(start_time, total_timeout))) {
- ThrowException(String::New("Timed out waiting for process to terminate"));
+      isolate->ThrowException(String::NewFromUtf8(
+          isolate, "Timed out waiting for process to terminate"));
       kill(pid, SIGINT);
       return false;
     }
@@ -405,7 +411,7 @@
              sizeof(message),
              "Child killed by signal %d",
              child_info.si_status);
-    ThrowException(String::New(message));
+    isolate->ThrowException(String::NewFromUtf8(isolate, message));
     return false;
   }
   if (child_info.si_code == CLD_EXITED && child_info.si_status != 0) {
@@ -414,7 +420,7 @@
              sizeof(message),
              "Child exited with status %d",
              child_info.si_status);
-    ThrowException(String::New(message));
+    isolate->ThrowException(String::NewFromUtf8(isolate, message));
     return false;
   }

@@ -429,7 +435,7 @@
              sizeof(message),
              "Child killed by signal %d",
              WTERMSIG(child_status));
-    ThrowException(String::New(message));
+    isolate->ThrowException(String::NewFromUtf8(isolate, message));
     return false;
   }
   if (WEXITSTATUS(child_status) != 0) {
@@ -439,7 +445,7 @@
              sizeof(message),
              "Child exited with status %d",
              exit_status);
-    ThrowException(String::New(message));
+    isolate->ThrowException(String::NewFromUtf8(isolate, message));
     return false;
   }

@@ -458,8 +464,8 @@
   Handle<Array> command_args;
   if (args.Length() > 1) {
     if (!args[1]->IsArray()) {
-      args.GetIsolate()->ThrowException(
-          String::New("system: Argument 2 must be an array"));
+      args.GetIsolate()->ThrowException(String::NewFromUtf8(
+          args.GetIsolate(), "system: Argument 2 must be an array"));
       return;
     }
     command_args = Handle<Array>::Cast(args[1]);
@@ -467,13 +473,13 @@
     command_args = Array::New(0);
   }
   if (command_args->Length() > ExecArgs::kMaxArgs) {
-    args.GetIsolate()->ThrowException(
-        String::New("Too many arguments to system()"));
+    args.GetIsolate()->ThrowException(String::NewFromUtf8(
+        args.GetIsolate(), "Too many arguments to system()"));
     return;
   }
   if (args.Length() < 1) {
-    args.GetIsolate()->ThrowException(
-        String::New("Too few arguments to system()"));
+    args.GetIsolate()->ThrowException(String::NewFromUtf8(
+        args.GetIsolate(), "Too few arguments to system()"));
     return;
   }

@@ -481,7 +487,7 @@
   gettimeofday(&start_time, NULL);

   ExecArgs exec_args;
-  if (!exec_args.Init(args[0], command_args)) {
+  if (!exec_args.Init(args.GetIsolate(), args[0], command_args)) {
     return;
   }
   int exec_error_fds[2];
@@ -489,12 +495,12 @@

   if (pipe(exec_error_fds) != 0) {
     args.GetIsolate()->ThrowException(
-        String::New("pipe syscall failed."));
+        String::NewFromUtf8(args.GetIsolate(), "pipe syscall failed."));
     return;
   }
   if (pipe(stdout_fds) != 0) {
     args.GetIsolate()->ThrowException(
-        String::New("pipe syscall failed."));
+        String::NewFromUtf8(args.GetIsolate(), "pipe syscall failed."));
     return;
   }

@@ -511,9 +517,10 @@
   OpenFDCloser error_read_closer(exec_error_fds[kReadFD]);
   OpenFDCloser stdout_read_closer(stdout_fds[kReadFD]);

-  if (!ChildLaunchedOK(exec_error_fds)) return;
+  if (!ChildLaunchedOK(args.GetIsolate(), exec_error_fds)) return;

-  Handle<Value> accumulator = GetStdout(stdout_fds[kReadFD],
+  Handle<Value> accumulator = GetStdout(args.GetIsolate(),
+                                        stdout_fds[kReadFD],
                                         start_time,
                                         read_timeout,
                                         total_timeout);
@@ -523,7 +530,8 @@
     return;
   }

-  if (!WaitForChild(pid,
+  if (!WaitForChild(args.GetIsolate(),
+                    pid,
                     child_waiter,
                     start_time,
                     read_timeout,
@@ -538,17 +546,20 @@
void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
   if (args.Length() != 1) {
     const char* message = "chdir() takes one argument";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   String::Utf8Value directory(args[0]);
   if (*directory == NULL) {
const char* message = "os.chdir(): String conversion of argument failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   if (chdir(*directory) != 0) {
-    args.GetIsolate()->ThrowException(String::New(strerror(errno)));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), strerror(errno)));
     return;
   }
 }
@@ -557,7 +568,8 @@
 void Shell::SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args) {
   if (args.Length() != 1) {
     const char* message = "umask() takes one argument";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   if (args[0]->IsNumber()) {
@@ -567,50 +579,51 @@
     return;
   } else {
     const char* message = "umask() argument must be numeric";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
 }


-static bool CheckItsADirectory(char* directory) {
+static bool CheckItsADirectory(Isolate* isolate, char* directory) {
   struct stat stat_buf;
   int stat_result = stat(directory, &stat_buf);
   if (stat_result != 0) {
-    ThrowException(String::New(strerror(errno)));
+    isolate->ThrowException(String::NewFromUtf8(isolate, strerror(errno)));
     return false;
   }
   if ((stat_buf.st_mode & S_IFDIR) != 0) return true;
-  ThrowException(String::New(strerror(EEXIST)));
+  isolate->ThrowException(String::NewFromUtf8(isolate, strerror(EEXIST)));
   return false;
 }


// Returns true for success. Creates intermediate directories as needed. No
 // error if the directory exists already.
-static bool mkdirp(char* directory, mode_t mask) {
+static bool mkdirp(Isolate* isolate, char* directory, mode_t mask) {
   int result = mkdir(directory, mask);
   if (result == 0) return true;
   if (errno == EEXIST) {
-    return CheckItsADirectory(directory);
+    return CheckItsADirectory(isolate, directory);
   } else if (errno == ENOENT) {  // Intermediate path element is missing.
     char* last_slash = strrchr(directory, '/');
     if (last_slash == NULL) {
-      ThrowException(String::New(strerror(errno)));
+ isolate->ThrowException(String::NewFromUtf8(isolate, strerror(errno)));
       return false;
     }
     *last_slash = 0;
-    if (!mkdirp(directory, mask)) return false;
+    if (!mkdirp(isolate, directory, mask)) return false;
     *last_slash = '/';
     result = mkdir(directory, mask);
     if (result == 0) return true;
     if (errno == EEXIST) {
-      return CheckItsADirectory(directory);
+      return CheckItsADirectory(isolate, directory);
     }
-    ThrowException(String::New(strerror(errno)));
+    isolate->ThrowException(String::NewFromUtf8(isolate, strerror(errno)));
     return false;
   } else {
-    ThrowException(String::New(strerror(errno)));
+    isolate->ThrowException(String::NewFromUtf8(isolate, strerror(errno)));
     return false;
   }
 }
@@ -623,34 +636,39 @@
       mask = args[1]->Int32Value();
     } else {
       const char* message = "mkdirp() second argument must be numeric";
-      args.GetIsolate()->ThrowException(String::New(message));
+      args.GetIsolate()->ThrowException(
+          String::NewFromUtf8(args.GetIsolate(), message));
       return;
     }
   } else if (args.Length() != 1) {
     const char* message = "mkdirp() takes one or two arguments";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   String::Utf8Value directory(args[0]);
   if (*directory == NULL) {
const char* message = "os.mkdirp(): String conversion of argument failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
-  mkdirp(*directory, mask);
+  mkdirp(args.GetIsolate(), *directory, mask);
 }


void Shell::RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) {
   if (args.Length() != 1) {
     const char* message = "rmdir() takes one or two arguments";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   String::Utf8Value directory(args[0]);
   if (*directory == NULL) {
const char* message = "os.rmdir(): String conversion of argument failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   rmdir(*directory);
@@ -660,7 +678,8 @@
void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
   if (args.Length() != 2) {
     const char* message = "setenv() takes two arguments";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   String::Utf8Value var(args[0]);
@@ -668,13 +687,15 @@
   if (*var == NULL) {
     const char* message =
         "os.setenv(): String conversion of variable name failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   if (*value == NULL) {
     const char* message =
         "os.setenv(): String conversion of variable contents failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   setenv(*var, *value, 1);
@@ -684,29 +705,37 @@
void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) {
   if (args.Length() != 1) {
     const char* message = "unsetenv() takes one argument";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   String::Utf8Value var(args[0]);
   if (*var == NULL) {
     const char* message =
         "os.setenv(): String conversion of variable name failed.";
-    args.GetIsolate()->ThrowException(String::New(message));
+    args.GetIsolate()->ThrowException(
+        String::NewFromUtf8(args.GetIsolate(), message));
     return;
   }
   unsetenv(*var);
 }


-void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
-  os_templ->Set(String::New("system"), FunctionTemplate::New(System));
- os_templ->Set(String::New("chdir"), FunctionTemplate::New(ChangeDirectory)); - os_templ->Set(String::New("setenv"), FunctionTemplate::New(SetEnvironment));
-  os_templ->Set(String::New("unsetenv"),
+void Shell::AddOSMethods(Isolate* isolate, Handle<ObjectTemplate> os_templ) {
+  os_templ->Set(String::NewFromUtf8(isolate, "system"),
+                FunctionTemplate::New(System));
+  os_templ->Set(String::NewFromUtf8(isolate, "chdir"),
+                FunctionTemplate::New(ChangeDirectory));
+  os_templ->Set(String::NewFromUtf8(isolate, "setenv"),
+                FunctionTemplate::New(SetEnvironment));
+  os_templ->Set(String::NewFromUtf8(isolate, "unsetenv"),
                 FunctionTemplate::New(UnsetEnvironment));
-  os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask));
- os_templ->Set(String::New("mkdirp"), FunctionTemplate::New(MakeDirectory)); - os_templ->Set(String::New("rmdir"), FunctionTemplate::New(RemoveDirectory));
+  os_templ->Set(String::NewFromUtf8(isolate, "umask"),
+                FunctionTemplate::New(SetUMask));
+  os_templ->Set(String::NewFromUtf8(isolate, "mkdirp"),
+                FunctionTemplate::New(MakeDirectory));
+  os_templ->Set(String::NewFromUtf8(isolate, "rmdir"),
+                FunctionTemplate::New(RemoveDirectory));
 }

 }  // namespace v8
=======================================
--- /branches/bleeding_edge/src/d8-windows.cc   Tue Dec  7 11:01:02 2010 UTC
+++ /branches/bleeding_edge/src/d8-windows.cc   Fri Nov 22 12:35:39 2013 UTC
@@ -35,7 +35,7 @@
 namespace v8 {


-void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
+void Shell::AddOSMethods(Isolate* isolate, Handle<ObjectTemplate> os_templ) {
 }


=======================================
--- /branches/bleeding_edge/src/d8.cc   Thu Nov 21 13:47:37 2013 UTC
+++ /branches/bleeding_edge/src/d8.cc   Fri Nov 22 12:35:39 2013 UTC
@@ -80,8 +80,8 @@
 namespace v8 {


-static Handle<Value> Throw(const char* message) {
-  return ThrowException(String::New(message));
+static Handle<Value> Throw(Isolate* isolate, const char* message) {
+  return isolate->ThrowException(String::NewFromUtf8(isolate, message));
 }


@@ -244,7 +244,8 @@
               v8::Local<v8::Context>::New(isolate, utility_context_);
           v8::Context::Scope context_scope(context);
           Handle<Object> global = context->Global();
-          Handle<Value> fun = global->Get(String::New("Stringify"));
+          Handle<Value> fun =
+              global->Get(String::NewFromUtf8(isolate, "Stringify"));
           Handle<Value> argv[1] = { result };
Handle<Value> s = Handle<Function>::Cast(fun)->Call(global, 1, argv);
           if (try_catch.HasCaught()) return true;
@@ -267,17 +268,16 @@
   data_->realms_ = new Persistent<Context>[1];
   data_->realms_[0].Reset(data_->isolate_,
                           data_->isolate_->GetEnteredContext());
-  data_->realm_shared_.Clear();
 }


 PerIsolateData::RealmScope::~RealmScope() {
   // Drop realms to avoid keeping them alive.
   for (int i = 0; i < data_->realm_count_; ++i)
-    data_->realms_[i].Dispose();
+    data_->realms_[i].Reset();
   delete[] data_->realms_;
   if (!data_->realm_shared_.IsEmpty())
-    data_->realm_shared_.Dispose();
+    data_->realm_shared_.Reset();
 }


@@ -313,7 +313,7 @@
   Isolate* isolate = args.GetIsolate();
   PerIsolateData* data = PerIsolateData::Get(isolate);
   if (args.Length() < 1 || !args[0]->IsObject()) {
-    Throw("Invalid argument");
+    Throw(args.GetIsolate(), "Invalid argument");
     return;
   }
   int index = data->RealmFind(args[0]->ToObject()->CreationContext());
@@ -327,12 +327,12 @@
 void Shell::RealmGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
   PerIsolateData* data = PerIsolateData::Get(args.GetIsolate());
   if (args.Length() < 1 || !args[0]->IsNumber()) {
-    Throw("Invalid argument");
+    Throw(args.GetIsolate(), "Invalid argument");
     return;
   }
   int index = args[0]->Uint32Value();
   if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
-    Throw("Invalid realm index");
+    Throw(args.GetIsolate(), "Invalid realm index");
     return;
   }
   args.GetReturnValue().Set(
@@ -363,18 +363,17 @@
   Isolate* isolate = args.GetIsolate();
   PerIsolateData* data = PerIsolateData::Get(isolate);
   if (args.Length() < 1 || !args[0]->IsNumber()) {
-    Throw("Invalid argument");
+    Throw(args.GetIsolate(), "Invalid argument");
     return;
   }
   int index = args[0]->Uint32Value();
   if (index >= data->realm_count_ || data->realms_[index].IsEmpty() ||
       index == 0 ||
       index == data->realm_current_ || index == data->realm_switch_) {
-    Throw("Invalid realm index");
+    Throw(args.GetIsolate(), "Invalid realm index");
     return;
   }
-  data->realms_[index].Dispose();
-  data->realms_[index].Clear();
+  data->realms_[index].Reset();
 }


@@ -383,12 +382,12 @@
   Isolate* isolate = args.GetIsolate();
   PerIsolateData* data = PerIsolateData::Get(isolate);
   if (args.Length() < 1 || !args[0]->IsNumber()) {
-    Throw("Invalid argument");
+    Throw(args.GetIsolate(), "Invalid argument");
     return;
   }
   int index = args[0]->Uint32Value();
   if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
-    Throw("Invalid realm index");
+    Throw(args.GetIsolate(), "Invalid realm index");
     return;
   }
   data->realm_switch_ = index;
@@ -400,12 +399,12 @@
   Isolate* isolate = args.GetIsolate();
   PerIsolateData* data = PerIsolateData::Get(isolate);
   if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsString()) {
-    Throw("Invalid argument");
+    Throw(args.GetIsolate(), "Invalid argument");
     return;
   }
   int index = args[0]->Uint32Value();
   if (index >= data->realm_count_ || data->realms_[index].IsEmpty()) {
-    Throw("Invalid realm index");
+    Throw(args.GetIsolate(), "Invalid realm index");
     return;
   }
   Handle<Script> script = Script::New(args[1]->ToString());
@@ -432,7 +431,6 @@
                            const PropertyCallbackInfo<void>& info) {
   Isolate* isolate = info.GetIsolate();
   PerIsolateData* data = PerIsolateData::Get(isolate);
-  if (!data->realm_shared_.IsEmpty()) data->realm_shared_.Dispose();
   data->realm_shared_.Reset(isolate, value);
 }

@@ -472,12 +470,12 @@
 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
   String::Utf8Value file(args[0]);
   if (*file == NULL) {
-    Throw("Error loading file");
+    Throw(args.GetIsolate(), "Error loading file");
     return;
   }
   Handle<String> source = ReadFile(args.GetIsolate(), *file);
   if (source.IsEmpty()) {
-    Throw("Error loading file");
+    Throw(args.GetIsolate(), "Error loading file");
     return;
   }
   args.GetReturnValue().Set(source);
@@ -487,7 +485,7 @@
 Handle<String> Shell::ReadFromStdin(Isolate* isolate) {
   static const int kBufferSize = 256;
   char buffer[kBufferSize];
-  Handle<String> accumulator = String::New("");
+  Handle<String> accumulator = String::NewFromUtf8(isolate, "");
   int length;
   while (true) {
// Continue reading if the line ends with an escape '\\' or the line has
@@ -503,12 +501,18 @@
     if (length == 0) {
       return accumulator;
     } else if (buffer[length-1] != '\n') {
- accumulator = String::Concat(accumulator, String::New(buffer, length));
+      accumulator = String::Concat(
+          accumulator,
+ String::NewFromUtf8(isolate, buffer, String::kNormalString, length));
     } else if (length > 1 && buffer[length-2] == '\\') {
       buffer[length-2] = '\n';
- accumulator = String::Concat(accumulator, String::New(buffer, length-1));
+      accumulator = String::Concat(
+          accumulator, String::NewFromUtf8(isolate, buffer,
+ String::kNormalString, length - 1));
     } else {
-      return String::Concat(accumulator, String::New(buffer, length-1));
+      return String::Concat(
+          accumulator, String::NewFromUtf8(isolate, buffer,
+ String::kNormalString, length - 1));
     }
   }
 }
@@ -519,20 +523,20 @@
     HandleScope handle_scope(args.GetIsolate());
     String::Utf8Value file(args[i]);
     if (*file == NULL) {
-      Throw("Error loading file");
+      Throw(args.GetIsolate(), "Error loading file");
       return;
     }
     Handle<String> source = ReadFile(args.GetIsolate(), *file);
     if (source.IsEmpty()) {
-      Throw("Error loading file");
+      Throw(args.GetIsolate(), "Error loading file");
       return;
     }
     if (!ExecuteString(args.GetIsolate(),
                        source,
-                       String::New(*file),
+                       String::NewFromUtf8(args.GetIsolate(), *file),
                        false,
                        true)) {
-      Throw("Error executing file");
+      Throw(args.GetIsolate(), "Error executing file");
       return;
     }
   }
@@ -547,7 +551,8 @@


 void Shell::Version(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  args.GetReturnValue().Set(String::New(V8::GetVersion()));
+  args.GetReturnValue().Set(
+      String::NewFromUtf8(args.GetIsolate(), V8::GetVersion()));
 }


@@ -555,7 +560,7 @@
   HandleScope handle_scope(isolate);
 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
   Handle<Context> utility_context;
-  bool enter_context = !Context::InContext();
+  bool enter_context = !isolate->InContext();
   if (enter_context) {
     utility_context = Local<Context>::New(isolate, utility_context_);
     utility_context->Enter();
@@ -610,7 +615,8 @@
       v8::Local<v8::Context>::New(isolate, utility_context_);
   v8::Context::Scope context_scope(utility_context);
   Handle<Object> global = utility_context->Global();
-  Handle<Value> fun = global->Get(String::New("GetCompletions"));
+  Handle<Value> fun =
+      global->Get(String::NewFromUtf8(isolate, "GetCompletions"));
   static const int kArgc = 3;
   v8::Local<v8::Context> evaluation_context =
       v8::Local<v8::Context>::New(isolate, evaluation_context_);
@@ -628,7 +634,8 @@
       v8::Local<v8::Context>::New(isolate, utility_context_);
   v8::Context::Scope context_scope(context);
   Handle<Object> global = context->Global();
-  Handle<Value> fun = global->Get(String::New("DebugMessageDetails"));
+  Handle<Value> fun =
+      global->Get(String::NewFromUtf8(isolate, "DebugMessageDetails"));
   static const int kArgc = 1;
   Handle<Value> argv[kArgc] = { message };
Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
@@ -643,7 +650,8 @@
       v8::Local<v8::Context>::New(isolate, utility_context_);
   v8::Context::Scope context_scope(context);
   Handle<Object> global = context->Global();
- Handle<Value> fun = global->Get(String::New("DebugCommandToJSONRequest"));
+  Handle<Value> fun =
+ global->Get(String::NewFromUtf8(isolate, "DebugCommandToJSONRequest"));
   static const int kArgc = 1;
   Handle<Value> argv[kArgc] = { command };
Handle<Value> val = Handle<Function>::Cast(fun)->Call(global, kArgc, argv);
@@ -782,8 +790,8 @@
   debug->Load();
   i::Handle<i::JSObject> js_debug
       = i::Handle<i::JSObject>(debug->debug_context()->global_object());
-  utility_context->Global()->Set(String::New("$debug"),
-                                  Utils::ToLocal(js_debug));
+  utility_context->Global()->Set(String::NewFromUtf8(isolate, "$debug"),
+                                 Utils::ToLocal(js_debug));
   debug->debug_context()->set_security_token(
       reinterpret_cast<i::Isolate*>(isolate)->heap()->undefined_value());
 #endif  // ENABLE_DEBUGGER_SUPPORT
@@ -794,10 +802,12 @@
       i::NativesCollection<i::D8>::GetRawScriptSource(source_index);
   i::Vector<const char> shell_source_name =
       i::NativesCollection<i::D8>::GetScriptName(source_index);
-  Handle<String> source = String::New(shell_source.start(),
-      shell_source.length());
-  Handle<String> name = String::New(shell_source_name.start(),
-      shell_source_name.length());
+  Handle<String> source =
+ String::NewFromUtf8(isolate, shell_source.start(), String::kNormalString,
+                          shell_source.length());
+  Handle<String> name =
+      String::NewFromUtf8(isolate, shell_source_name.start(),
+ String::kNormalString, shell_source_name.length());
   Handle<Script> script = Script::Compile(source, name);
   script->Run();
// Mark the d8 shell script as native to avoid it showing up as normal source
@@ -850,48 +860,55 @@

 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
   Handle<ObjectTemplate> global_template = ObjectTemplate::New();
-  global_template->Set(String::New("print"), FunctionTemplate::New(Print));
-  global_template->Set(String::New("write"), FunctionTemplate::New(Write));
-  global_template->Set(String::New("read"), FunctionTemplate::New(Read));
-  global_template->Set(String::New("readbuffer"),
+  global_template->Set(String::NewFromUtf8(isolate, "print"),
+                       FunctionTemplate::New(Print));
+  global_template->Set(String::NewFromUtf8(isolate, "write"),
+                       FunctionTemplate::New(Write));
+  global_template->Set(String::NewFromUtf8(isolate, "read"),
+                       FunctionTemplate::New(Read));
+  global_template->Set(String::NewFromUtf8(isolate, "readbuffer"),
                        FunctionTemplate::New(ReadBuffer));
-  global_template->Set(String::New("readline"),
+  global_template->Set(String::NewFromUtf8(isolate, "readline"),
                        FunctionTemplate::New(ReadLine));
-  global_template->Set(String::New("load"), FunctionTemplate::New(Load));
-  global_template->Set(String::New("quit"), FunctionTemplate::New(Quit));
- global_template->Set(String::New("version"), FunctionTemplate::New(Version));
+  global_template->Set(String::NewFromUtf8(isolate, "load"),
+                       FunctionTemplate::New(Load));
+  global_template->Set(String::NewFromUtf8(isolate, "quit"),
+                       FunctionTemplate::New(Quit));
+  global_template->Set(String::NewFromUtf8(isolate, "version"),
+                       FunctionTemplate::New(Version));

   // Bind the Realm object.
   Handle<ObjectTemplate> realm_template = ObjectTemplate::New();
-  realm_template->Set(String::New("current"),
+  realm_template->Set(String::NewFromUtf8(isolate, "current"),
                       FunctionTemplate::New(RealmCurrent));
-  realm_template->Set(String::New("owner"),
+  realm_template->Set(String::NewFromUtf8(isolate, "owner"),
                       FunctionTemplate::New(RealmOwner));
-  realm_template->Set(String::New("global"),
+  realm_template->Set(String::NewFromUtf8(isolate, "global"),
                       FunctionTemplate::New(RealmGlobal));
-  realm_template->Set(String::New("create"),
+  realm_template->Set(String::NewFromUtf8(isolate, "create"),
                       FunctionTemplate::New(RealmCreate));
-  realm_template->Set(String::New("dispose"),
+  realm_template->Set(String::NewFromUtf8(isolate, "dispose"),
                       FunctionTemplate::New(RealmDispose));
-  realm_template->Set(String::New("switch"),
+  realm_template->Set(String::NewFromUtf8(isolate, "switch"),
                       FunctionTemplate::New(RealmSwitch));
-  realm_template->Set(String::New("eval"),
+  realm_template->Set(String::NewFromUtf8(isolate, "eval"),
                       FunctionTemplate::New(RealmEval));
-  realm_template->SetAccessor(String::New("shared"),
+  realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"),
                               RealmSharedGet, RealmSharedSet);
-  global_template->Set(String::New("Realm"), realm_template);
+ global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template);

 #ifndef V8_SHARED
   Handle<ObjectTemplate> performance_template = ObjectTemplate::New();
-  performance_template->Set(String::New("now"),
+  performance_template->Set(String::NewFromUtf8(isolate, "now"),
                             FunctionTemplate::New(PerformanceNow));
-  global_template->Set(String::New("performance"), performance_template);
+  global_template->Set(String::NewFromUtf8(isolate, "performance"),
+                       performance_template);
 #endif  // V8_SHARED

 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64)
   Handle<ObjectTemplate> os_templ = ObjectTemplate::New();
-  AddOSMethods(os_templ);
-  global_template->Set(String::New("os"), os_templ);
+  AddOSMethods(isolate, os_templ);
+  global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ);
 #endif  // V8_SHARED

   return global_template;
@@ -966,7 +983,7 @@
   }
   i::Handle<i::JSArray> arguments_jsarray =
       factory->NewJSArrayWithElements(arguments_array);
-  context->Global()->Set(String::New("arguments"),
+  context->Global()->Set(String::NewFromUtf8(isolate, "arguments"),
                          Utils::ToLocal(arguments_jsarray));
 #endif  // V8_SHARED
   return handle_scope.Close(context);
@@ -1089,7 +1106,7 @@
       -static_cast<intptr_t>(byte_length));

   delete[] data;
-  array_buffer->Dispose();
+  array_buffer->Reset();
 }


@@ -1098,7 +1115,7 @@
   String::Utf8Value filename(args[0]);
   int length;
   if (*filename == NULL) {
-    Throw("Error loading file");
+    Throw(args.GetIsolate(), "Error loading file");
     return;
   }

@@ -1106,7 +1123,7 @@
   uint8_t* data = reinterpret_cast<uint8_t*>(
       ReadChars(args.GetIsolate(), *filename, &length));
   if (data == NULL) {
-    Throw("Error reading file");
+    Throw(args.GetIsolate(), "Error reading file");
     return;
   }
   Handle<v8::ArrayBuffer> buffer = ArrayBuffer::New(data, length);
@@ -1147,7 +1164,8 @@
   int size = 0;
   char* chars = ReadChars(isolate, name, &size);
   if (chars == NULL) return Handle<String>();
-  Handle<String> result = String::New(chars, size);
+  Handle<String> result =
+      String::NewFromUtf8(isolate, chars, String::kNormalString, size);
   delete[] chars;
   return result;
 }
@@ -1160,7 +1178,7 @@
       v8::Local<v8::Context>::New(isolate, evaluation_context_);
   v8::Context::Scope context_scope(context);
   PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
-  Handle<String> name = String::New("(d8)");
+  Handle<String> name = String::NewFromUtf8(isolate, "(d8)");
   LineEditor* console = LineEditor::Get();
printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name());
   console->Open(isolate);
@@ -1229,7 +1247,8 @@
         Shell::Exit(1);
       }

- Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
+      Shell::ExecuteString(
+ isolate_, str, String::NewFromUtf8(isolate_, filename), false, false);
     }

     ptr = next_line;
@@ -1253,8 +1272,8 @@
     if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
       // Execute argument given to -e option directly.
       HandleScope handle_scope(isolate);
-      Handle<String> file_name = String::New("unnamed");
-      Handle<String> source = String::New(argv_[i + 1]);
+      Handle<String> file_name = String::NewFromUtf8(isolate, "unnamed");
+      Handle<String> source = String::NewFromUtf8(isolate, argv_[i + 1]);
       if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
         exception_was_thrown = true;
         break;
@@ -1265,7 +1284,7 @@
     } else {
       // Use all other arguments as names of files to load and run.
       HandleScope handle_scope(isolate);
-      Handle<String> file_name = String::New(arg);
+      Handle<String> file_name = String::NewFromUtf8(isolate, arg);
       Handle<String> source = ReadFile(isolate, arg);
       if (source.IsEmpty()) {
         printf("Error reading '%s'\n", arg);
@@ -1287,7 +1306,8 @@
   int size;
   char* chars = ReadChars(isolate, name, &size);
   if (chars == NULL) return Handle<String>();
-  Handle<String> result = String::New(chars, size);
+  Handle<String> result =
+      String::NewFromUtf8(isolate, chars, String::kNormalString, size);
   delete[] chars;
   return result;
 }
=======================================
--- /branches/bleeding_edge/src/d8.gyp  Fri Nov 22 10:57:55 2013 UTC
+++ /branches/bleeding_edge/src/d8.gyp  Fri Nov 22 12:35:39 2013 UTC
@@ -33,12 +33,6 @@
     'v8_enable_vtunejit%': 0,
     'v8_enable_i18n_support%': 1,
   },
-  'target_defaults': {
-    'variables': {
-      # TODO(jochen): enable warnings.
-      'v8_deprecation_warnings': 0,
-    },
-  },
   'includes': ['../build/toolchain.gypi', '../build/features.gypi'],
   'targets': [
     {
=======================================
--- /branches/bleeding_edge/src/d8.h    Thu Nov 21 13:47:37 2013 UTC
+++ /branches/bleeding_edge/src/d8.h    Fri Nov 22 12:35:39 2013 UTC
@@ -377,7 +377,8 @@
static void MakeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args); static void RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args);

-  static void AddOSMethods(Handle<ObjectTemplate> os_template);
+  static void AddOSMethods(v8::Isolate* isolate,
+                           Handle<ObjectTemplate> os_template);

   static const char* kPrompt;
   static ShellOptions options;

--
--
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/groups/opt_out.

Reply via email to