Version 3.17.11

Added a version of the v8::HandleScope constructor with an v8::Isolate parameter and made AdjustAmountOfExternalAllocatedMemory an instance method of v8::Isolate. (issue 2487)

Fixed two register allocator bugs (off-by-one error/failure propagation). (issue 2576)

Fixed huge heap snapshot when a heavily shared context has many variables. (Chromium issue 145687)

Performance and stability improvements on all platforms.

git-svn-id: http://v8.googlecode.com/svn/trunk@13956 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/ChangeLog b/ChangeLog
index 9bc8efd..7565127 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2013-03-15: Version 3.17.11
+
+        Added a version of the v8::HandleScope constructor with an v8::Isolate
+        parameter and made AdjustAmountOfExternalAllocatedMemory an instance
+        method of v8::Isolate.
+        (issue 2487)
+
+        Fixed two register allocator bugs (off-by-one error/failure
+        propagation). (issue 2576)
+
+        Fixed huge heap snapshot when a heavily shared context has many
+        variables. (Chromium issue 145687)
+
+        Performance and stability improvements on all platforms.
+
+
 2013-03-13: Version 3.17.10
 
         Fixed heap snapshot creation for Harmony collections. (issue 2535)
diff --git a/build/common.gypi b/build/common.gypi
index 6e12f26..a3c9ed0 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -74,8 +74,6 @@
     # Default arch variant for MIPS.
     'mips_arch_variant%': 'mips32r2',
 
-    'v8_enable_latin_1%': 1,
-
     'v8_enable_debugger_support%': 1,
 
     'v8_enable_backtrace%': 0,
@@ -116,9 +114,6 @@
   },
   'target_defaults': {
     'conditions': [
-      ['v8_enable_latin_1==1', {
-        'defines': ['ENABLE_LATIN_1',],
-      }],
       ['v8_enable_debugger_support==1', {
         'defines': ['ENABLE_DEBUGGER_SUPPORT',],
       }],
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index 4d3597a..c9eab3f 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -258,8 +258,9 @@
     kRegExp = 6,      // RegExp.
     kHeapNumber = 7,  // Number stored in the heap.
     kNative = 8,      // Native object (not from V8 heap).
-    kSynthetic = 9    // Synthetic object, usualy used for grouping
+    kSynthetic = 9,   // Synthetic object, usualy used for grouping
                       // snapshot items together.
+    kContext = 10     // Context
   };
 
   /** Returns node type (see HeapGraphNode::Type). */
diff --git a/include/v8.h b/include/v8.h
index 7016cb5..1e4d2f9 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -38,9 +38,6 @@
 #ifndef V8_H_
 #define V8_H_
 
-// TODO(dcarney): Remove once Latin-1 transitions in WebKit has stuck.
-#define V8_ONE_BYTE_STRINGS_ENABLED 1
-
 #include "v8stdint.h"
 
 #ifdef _WIN32
@@ -517,8 +514,11 @@
  */
 class V8EXPORT HandleScope {
  public:
+  // TODO(svenpanne) Deprecate me when Chrome is fixed!
   HandleScope();
 
+  HandleScope(Isolate* isolate);
+
   ~HandleScope();
 
   /**
@@ -562,6 +562,7 @@
     }
   };
 
+  void Initialize(Isolate* isolate);
   void Leave();
 
   internal::Isolate* isolate_;
@@ -3007,6 +3008,21 @@
    */
   void GetHeapStatistics(HeapStatistics* heap_statistics);
 
+  /**
+   * Adjusts the amount of registered external memory. Used to give V8 an
+   * indication of the amount of externally allocated memory that is kept alive
+   * by JavaScript objects. V8 uses this to decide when to perform global
+   * garbage collections. Registering externally allocated memory will trigger
+   * global garbage collections more often than it would otherwise in an attempt
+   * to garbage collect the JavaScript objects that keep the externally
+   * allocated memory alive.
+   *
+   * \param change_in_bytes the change in externally allocated memory that is
+   *   kept alive by JavaScript objects.
+   * \returns the adjusted value.
+   */
+  intptr_t AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes);
+
  private:
   Isolate();
   Isolate(const Isolate&);
@@ -3487,20 +3503,8 @@
   static void SetJitCodeEventHandler(JitCodeEventOptions options,
                                      JitCodeEventHandler event_handler);
 
-  /**
-   * Adjusts the amount of registered external memory.  Used to give
-   * V8 an indication of the amount of externally allocated memory
-   * that is kept alive by JavaScript objects.  V8 uses this to decide
-   * when to perform global garbage collections.  Registering
-   * externally allocated memory will trigger global garbage
-   * collections more often than otherwise in an attempt to garbage
-   * collect the JavaScript objects keeping the externally allocated
-   * memory alive.
-   *
-   * \param change_in_bytes the change in externally allocated memory
-   *   that is kept alive by JavaScript objects.
-   * \returns the adjusted value.
-   */
+  // TODO(svenpanne) Really deprecate me when Chrome is fixed.
+  /** Deprecated. Use Isolate::AdjustAmountOfExternalAllocatedMemory instead. */
   static intptr_t AdjustAmountOfExternalAllocatedMemory(
       intptr_t change_in_bytes);
 
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index 6549f4c..b5b6367 100644
--- a/samples/lineprocessor.cc
+++ b/samples/lineprocessor.cc
@@ -98,13 +98,14 @@
 };
 
 const char* ToCString(const v8::String::Utf8Value& value);
-void ReportException(v8::TryCatch* handler);
+void ReportException(v8::Isolate* isolate, v8::TryCatch* handler);
 v8::Handle<v8::String> ReadFile(const char* name);
 v8::Handle<v8::String> ReadLine();
 
 v8::Handle<v8::Value> Print(const v8::Arguments& args);
 v8::Handle<v8::Value> ReadLine(const v8::Arguments& args);
-bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context,
+bool RunCppCycle(v8::Handle<v8::Script> script,
+                 v8::Local<v8::Context> context,
                  bool report_exceptions);
 
 
@@ -132,7 +133,8 @@
 
 int RunMain(int argc, char* argv[]) {
   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
-  v8::HandleScope handle_scope;
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::HandleScope handle_scope(isolate);
 
   v8::Handle<v8::String> script_source(NULL);
   v8::Handle<v8::Value> script_name(NULL);
@@ -213,9 +215,9 @@
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
   debug_message_context =
-      v8::Persistent<v8::Context>::New(context->GetIsolate(), context);
+      v8::Persistent<v8::Context>::New(isolate, context);
 
-  v8::Locker locker(context->GetIsolate());
+  v8::Locker locker(isolate);
 
   if (support_callback) {
     v8::Debug::SetDebugMessageDispatchHandler(DispatchDebugMessages, true);
@@ -236,7 +238,7 @@
     if (script.IsEmpty()) {
       // Print errors that happened during compilation.
       if (report_exceptions)
-        ReportException(&try_catch);
+        ReportException(isolate, &try_catch);
       return 1;
     }
   }
@@ -247,13 +249,14 @@
     script->Run();
     if (try_catch.HasCaught()) {
       if (report_exceptions)
-        ReportException(&try_catch);
+        ReportException(isolate, &try_catch);
       return 1;
     }
   }
 
   if (cycle_type == CycleInCpp) {
-    bool res = RunCppCycle(script, v8::Context::GetCurrent(),
+    bool res = RunCppCycle(script,
+                           v8::Context::GetCurrent(),
                            report_exceptions);
     return !res;
   } else {
@@ -263,15 +266,16 @@
 }
 
 
-bool RunCppCycle(v8::Handle<v8::Script> script, v8::Local<v8::Context> context,
+bool RunCppCycle(v8::Handle<v8::Script> script,
+                 v8::Local<v8::Context> context,
                  bool report_exceptions) {
+  v8::Isolate* isolate = context->GetIsolate();
 #ifdef ENABLE_DEBUGGER_SUPPORT
-  v8::Locker lock(v8::Isolate::GetCurrent());
+  v8::Locker lock(isolate);
 #endif  // ENABLE_DEBUGGER_SUPPORT
 
   v8::Handle<v8::String> fun_name = v8::String::New("ProcessLine");
-  v8::Handle<v8::Value> process_val =
-      v8::Context::GetCurrent()->Global()->Get(fun_name);
+  v8::Handle<v8::Value> process_val = context->Global()->Get(fun_name);
 
   // If there is no Process function, or if it is not a function,
   // bail out
@@ -286,7 +290,7 @@
 
 
   while (!feof(stdin)) {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
 
     v8::Handle<v8::String> input_line = ReadLine();
     if (input_line == v8::Undefined()) {
@@ -303,7 +307,7 @@
                                  argc, argv);
       if (try_catch.HasCaught()) {
         if (report_exceptions)
-          ReportException(&try_catch);
+          ReportException(isolate, &try_catch);
         return false;
       }
     }
@@ -350,8 +354,8 @@
 }
 
 
-void ReportException(v8::TryCatch* try_catch) {
-  v8::HandleScope handle_scope;
+void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
+  v8::HandleScope handle_scope(isolate);
   v8::String::Utf8Value exception(try_catch->Exception());
   const char* exception_string = ToCString(exception);
   v8::Handle<v8::Message> message = try_catch->Message();
@@ -389,7 +393,7 @@
 v8::Handle<v8::Value> Print(const v8::Arguments& args) {
   bool first = true;
   for (int i = 0; i < args.Length(); i++) {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(args.GetIsolate());
     if (first) {
       first = false;
     } else {
diff --git a/samples/process.cc b/samples/process.cc
index c3d1773..4dcc09a 100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -79,7 +79,8 @@
  public:
   // Creates a new processor that processes requests by invoking the
   // Process function of the JavaScript script given as an argument.
-  explicit JsHttpRequestProcessor(Handle<String> script) : script_(script) { }
+  JsHttpRequestProcessor(Isolate* isolate, Handle<String> script)
+      : isolate_(isolate), script_(script) { }
   virtual ~JsHttpRequestProcessor();
 
   virtual bool Initialize(map<string, string>* opts,
@@ -97,8 +98,8 @@
 
   // Constructs the template that describes the JavaScript wrapper
   // type for requests.
-  static Handle<ObjectTemplate> MakeRequestTemplate();
-  static Handle<ObjectTemplate> MakeMapTemplate();
+  static Handle<ObjectTemplate> MakeRequestTemplate(Isolate* isolate);
+  static Handle<ObjectTemplate> MakeMapTemplate(Isolate* isolate);
 
   // Callbacks that access the individual fields of request objects.
   static Handle<Value> GetPath(Local<String> name, const AccessorInfo& info);
@@ -121,8 +122,9 @@
   Handle<Object> WrapRequest(HttpRequest* obj);
   static HttpRequest* UnwrapRequest(Handle<Object> obj);
 
-  Isolate* GetIsolate() { return context_->GetIsolate(); }
+  Isolate* GetIsolate() { return isolate_; }
 
+  Isolate* isolate_;
   Handle<String> script_;
   Persistent<Context> context_;
   Persistent<Function> process_;
@@ -136,12 +138,12 @@
 
 
 static Handle<Value> LogCallback(const Arguments& args) {
-  if (args.Length() < 1) return v8::Undefined();
-  HandleScope scope;
+  if (args.Length() < 1) return Undefined();
+  HandleScope scope(args.GetIsolate());
   Handle<Value> arg = args[0];
   String::Utf8Value value(arg);
   HttpRequestProcessor::Log(*value);
-  return v8::Undefined();
+  return Undefined();
 }
 
 
@@ -149,7 +151,7 @@
 bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
                                         map<string, string>* output) {
   // Create a handle scope to hold the temporary references.
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // Create a template for the global object where we set the
   // built-in global functions.
@@ -197,7 +199,7 @@
 
 
 bool JsHttpRequestProcessor::ExecuteScript(Handle<String> script) {
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // We're just about to compile the script; set up an error handler to
   // catch any exceptions the script might throw.
@@ -227,7 +229,7 @@
 
 bool JsHttpRequestProcessor::InstallMaps(map<string, string>* opts,
                                          map<string, string>* output) {
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // Wrap the map object in a JavaScript wrapper
   Handle<Object> opts_obj = WrapMap(opts);
@@ -244,7 +246,7 @@
 
 bool JsHttpRequestProcessor::Process(HttpRequest* request) {
   // Create a handle scope to keep the temporary object references.
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // Enter this processor's context so all the remaining operations
   // take place there
@@ -275,7 +277,7 @@
   // Dispose the persistent handles.  When noone else has any
   // references to the objects stored in the handles they will be
   // automatically reclaimed.
-  v8::Isolate* isolate = GetIsolate();
+  Isolate* isolate = GetIsolate();
   context_.Dispose(isolate);
   process_.Dispose(isolate);
 }
@@ -293,12 +295,12 @@
 // JavaScript object.
 Handle<Object> JsHttpRequestProcessor::WrapMap(map<string, string>* obj) {
   // Handle scope for temporary handles.
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // Fetch the template for creating JavaScript map wrappers.
   // It only has to be created once, which we do on demand.
   if (map_template_.IsEmpty()) {
-    Handle<ObjectTemplate> raw_template = MakeMapTemplate();
+    Handle<ObjectTemplate> raw_template = MakeMapTemplate(GetIsolate());
     map_template_ = Persistent<ObjectTemplate>::New(GetIsolate(), raw_template);
   }
   Handle<ObjectTemplate> templ = map_template_;
@@ -376,8 +378,9 @@
 }
 
 
-Handle<ObjectTemplate> JsHttpRequestProcessor::MakeMapTemplate() {
-  HandleScope handle_scope;
+Handle<ObjectTemplate> JsHttpRequestProcessor::MakeMapTemplate(
+    Isolate* isolate) {
+  HandleScope handle_scope(isolate);
 
   Handle<ObjectTemplate> result = ObjectTemplate::New();
   result->SetInternalFieldCount(1);
@@ -398,12 +401,12 @@
  */
 Handle<Object> JsHttpRequestProcessor::WrapRequest(HttpRequest* request) {
   // Handle scope for temporary handles.
-  HandleScope handle_scope;
+  HandleScope handle_scope(GetIsolate());
 
   // Fetch the template for creating JavaScript http request wrappers.
   // It only has to be created once, which we do on demand.
   if (request_template_.IsEmpty()) {
-    Handle<ObjectTemplate> raw_template = MakeRequestTemplate();
+    Handle<ObjectTemplate> raw_template = MakeRequestTemplate(GetIsolate());
     request_template_ =
         Persistent<ObjectTemplate>::New(GetIsolate(), raw_template);
   }
@@ -475,8 +478,9 @@
 }
 
 
-Handle<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate() {
-  HandleScope handle_scope;
+Handle<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate(
+    Isolate* isolate) {
+  HandleScope handle_scope(isolate);
 
   Handle<ObjectTemplate> result = ObjectTemplate::New();
   result->SetInternalFieldCount(1);
@@ -608,13 +612,14 @@
     fprintf(stderr, "No script was specified.\n");
     return 1;
   }
-  HandleScope scope;
+  Isolate* isolate = Isolate::GetCurrent();
+  HandleScope scope(isolate);
   Handle<String> source = ReadFile(file);
   if (source.IsEmpty()) {
     fprintf(stderr, "Error reading '%s'.\n", file.c_str());
     return 1;
   }
-  JsHttpRequestProcessor processor(source);
+  JsHttpRequestProcessor processor(isolate, source);
   map<string, string> output;
   if (!processor.Initialize(&options, &output)) {
     fprintf(stderr, "Error initializing processor.\n");
diff --git a/samples/shell.cc b/samples/shell.cc
index e9057f9..0b71c2c 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -47,8 +47,9 @@
 
 v8::Persistent<v8::Context> CreateShellContext();
 void RunShell(v8::Handle<v8::Context> context);
-int RunMain(int argc, char* argv[]);
-bool ExecuteString(v8::Handle<v8::String> source,
+int RunMain(v8::Isolate* isolate, int argc, char* argv[]);
+bool ExecuteString(v8::Isolate* isolate,
+                   v8::Handle<v8::String> source,
                    v8::Handle<v8::Value> name,
                    bool print_result,
                    bool report_exceptions);
@@ -58,7 +59,7 @@
 v8::Handle<v8::Value> Quit(const v8::Arguments& args);
 v8::Handle<v8::Value> Version(const v8::Arguments& args);
 v8::Handle<v8::String> ReadFile(const char* name);
-void ReportException(v8::TryCatch* handler);
+void ReportException(v8::Isolate* isolate, v8::TryCatch* handler);
 
 
 static bool run_shell;
@@ -66,20 +67,21 @@
 
 int main(int argc, char* argv[]) {
   v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
   run_shell = (argc == 1);
   int result;
   {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     v8::Persistent<v8::Context> context = CreateShellContext();
     if (context.IsEmpty()) {
       fprintf(stderr, "Error creating context\n");
       return 1;
     }
     context->Enter();
-    result = RunMain(argc, argv);
+    result = RunMain(isolate, argc, argv);
     if (run_shell) RunShell(context);
     context->Exit();
-    context.Dispose(context->GetIsolate());
+    context.Dispose(isolate);
   }
   v8::V8::Dispose();
   return result;
@@ -118,7 +120,7 @@
 v8::Handle<v8::Value> Print(const v8::Arguments& args) {
   bool first = true;
   for (int i = 0; i < args.Length(); i++) {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(args.GetIsolate());
     if (first) {
       first = false;
     } else {
@@ -158,7 +160,7 @@
 // JavaScript file.
 v8::Handle<v8::Value> Load(const v8::Arguments& args) {
   for (int i = 0; i < args.Length(); i++) {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(args.GetIsolate());
     v8::String::Utf8Value file(args[i]);
     if (*file == NULL) {
       return v8::ThrowException(v8::String::New("Error loading file"));
@@ -167,7 +169,11 @@
     if (source.IsEmpty()) {
       return v8::ThrowException(v8::String::New("Error loading file"));
     }
-    if (!ExecuteString(source, v8::String::New(*file), false, false)) {
+    if (!ExecuteString(args.GetIsolate(),
+                       source,
+                       v8::String::New(*file),
+                       false,
+                       false)) {
       return v8::ThrowException(v8::String::New("Error executing file"));
     }
   }
@@ -216,7 +222,7 @@
 
 
 // Process remaining command line arguments and execute files
-int RunMain(int argc, char* argv[]) {
+int RunMain(v8::Isolate* isolate, int argc, char* argv[]) {
   for (int i = 1; i < argc; i++) {
     const char* str = argv[i];
     if (strcmp(str, "--shell") == 0) {
@@ -232,7 +238,7 @@
       // Execute argument given to -e option directly.
       v8::Handle<v8::String> file_name = v8::String::New("unnamed");
       v8::Handle<v8::String> source = v8::String::New(argv[++i]);
-      if (!ExecuteString(source, file_name, false, true)) return 1;
+      if (!ExecuteString(isolate, source, file_name, false, true)) return 1;
     } else {
       // Use all other arguments as names of files to load and run.
       v8::Handle<v8::String> file_name = v8::String::New(str);
@@ -241,7 +247,7 @@
         fprintf(stderr, "Error reading '%s'\n", str);
         continue;
       }
-      if (!ExecuteString(source, file_name, false, true)) return 1;
+      if (!ExecuteString(isolate, source, file_name, false, true)) return 1;
     }
   }
   return 0;
@@ -260,25 +266,30 @@
     fprintf(stderr, "> ");
     char* str = fgets(buffer, kBufferSize, stdin);
     if (str == NULL) break;
-    v8::HandleScope handle_scope;
-    ExecuteString(v8::String::New(str), name, true, true);
+    v8::HandleScope handle_scope(context->GetIsolate());
+    ExecuteString(context->GetIsolate(),
+                  v8::String::New(str),
+                  name,
+                  true,
+                  true);
   }
   fprintf(stderr, "\n");
 }
 
 
 // Executes a string within the current v8 context.
-bool ExecuteString(v8::Handle<v8::String> source,
+bool ExecuteString(v8::Isolate* isolate,
+                   v8::Handle<v8::String> source,
                    v8::Handle<v8::Value> name,
                    bool print_result,
                    bool report_exceptions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(isolate);
   v8::TryCatch try_catch;
   v8::Handle<v8::Script> script = v8::Script::Compile(source, name);
   if (script.IsEmpty()) {
     // Print errors that happened during compilation.
     if (report_exceptions)
-      ReportException(&try_catch);
+      ReportException(isolate, &try_catch);
     return false;
   } else {
     v8::Handle<v8::Value> result = script->Run();
@@ -286,7 +297,7 @@
       assert(try_catch.HasCaught());
       // Print errors that happened during execution.
       if (report_exceptions)
-        ReportException(&try_catch);
+        ReportException(isolate, &try_catch);
       return false;
     } else {
       assert(!try_catch.HasCaught());
@@ -303,8 +314,8 @@
 }
 
 
-void ReportException(v8::TryCatch* try_catch) {
-  v8::HandleScope handle_scope;
+void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
+  v8::HandleScope handle_scope(isolate);
   v8::String::Utf8Value exception(try_catch->Exception());
   const char* exception_string = ToCString(exception);
   v8::Handle<v8::Message> message = try_catch->Message();
diff --git a/src/api.cc b/src/api.cc
index 4ec3936..47928a6 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -666,11 +666,21 @@
 
 
 HandleScope::HandleScope() {
-  i::Isolate* isolate = i::Isolate::Current();
-  API_ENTRY_CHECK(isolate, "HandleScope::HandleScope");
+  Initialize(reinterpret_cast<Isolate*>(i::Isolate::Current()));
+}
+
+
+HandleScope::HandleScope(Isolate* isolate) {
+  Initialize(isolate);
+}
+
+
+void HandleScope::Initialize(Isolate* isolate) {
+  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+  API_ENTRY_CHECK(internal_isolate, "HandleScope::HandleScope");
   v8::ImplementationUtilities::HandleScopeData* current =
-      isolate->handle_scope_data();
-  isolate_ = isolate;
+      internal_isolate->handle_scope_data();
+  isolate_ = internal_isolate;
   prev_next_ = current->next;
   prev_limit_ = current->limit;
   is_closed_ = false;
@@ -686,7 +696,6 @@
 
 
 void HandleScope::Leave() {
-  ASSERT(isolate_ == i::Isolate::Current());
   v8::ImplementationUtilities::HandleScopeData* current =
       isolate_->handle_scope_data();
   current->level--;
@@ -1884,7 +1893,7 @@
 v8::TryCatch::~TryCatch() {
   ASSERT(isolate_ == i::Isolate::Current());
   if (rethrow_) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate_));
     v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception());
     isolate_->UnregisterTryCatchHandler(this);
     v8::ThrowException(exc);
@@ -1976,7 +1985,7 @@
   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
   ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>());
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::Object> obj = Utils::OpenHandle(this);
   i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj);
   Local<String> result = Utils::ToLocal(raw_result);
@@ -1990,7 +1999,7 @@
     return Local<String>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSMessageObject> message =
       i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
   // Return this.script.name.
@@ -2009,7 +2018,7 @@
     return Local<Value>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSMessageObject> message =
       i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
   // Return this.script.data.
@@ -2027,7 +2036,7 @@
     return Local<v8::StackTrace>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSMessageObject> message =
       i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this));
   i::Handle<i::Object> stackFramesObj(message->stack_frames(), isolate);
@@ -2147,7 +2156,7 @@
   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
   ON_BAILOUT(isolate, "v8::Message::GetSourceLine()", return Local<String>());
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   EXCEPTION_PREAMBLE(isolate);
   i::Handle<i::Object> result = CallV8HeapFunction("GetSourceLine",
                                                    Utils::OpenHandle(this),
@@ -2177,7 +2186,7 @@
     return Local<StackFrame>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSArray> self = Utils::OpenHandle(this);
   i::Object* raw_object = self->GetElementNoExceptionThrown(index);
   i::Handle<i::JSObject> obj(i::JSObject::cast(raw_object));
@@ -2254,7 +2263,7 @@
     return Local<String>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSObject> self = Utils::OpenHandle(this);
   i::Handle<i::Object> name = GetProperty(self, "scriptName");
   if (!name->IsString()) {
@@ -2270,7 +2279,7 @@
     return Local<String>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSObject> self = Utils::OpenHandle(this);
   i::Handle<i::Object> name = GetProperty(self, "scriptNameOrSourceURL");
   if (!name->IsString()) {
@@ -2286,7 +2295,7 @@
     return Local<String>();
   }
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSObject> self = Utils::OpenHandle(this);
   i::Handle<i::Object> name = GetProperty(self, "functionName");
   if (!name->IsString()) {
@@ -3280,7 +3289,7 @@
   ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
              return false);
   ENTER_V8(isolate);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSObject> self = Utils::OpenHandle(this);
   return i::JSObject::DeleteElement(self, index)->IsTrue();
 }
@@ -3858,7 +3867,7 @@
   ENTER_V8(isolate);
   i::Logger::TimerEventScope timer_scope(
       isolate, i::Logger::TimerEventScope::v8_execute);
-  HandleScope scope;
+  HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Handle<i::JSFunction> function = Utils::OpenHandle(this);
   STATIC_ASSERT(sizeof(v8::Handle<v8::Value>) == sizeof(i::Object**));
   i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
@@ -4011,31 +4020,30 @@
 
   class Visitor {
    public:
-    explicit Visitor()
+    inline explicit Visitor()
       : utf8_length_(0),
         state_(kInitialState) {}
 
-    template<typename Char>
-    inline void Visit(const Char* chars, int length) {
+    void VisitOneByteString(const uint8_t* chars, int length) {
+      int utf8_length = 0;
+      // Add in length 1 for each non-ASCII character.
+      for (int i = 0; i < length; i++) {
+        utf8_length += *chars++ >> 7;
+      }
+      // Add in length 1 for each character.
+      utf8_length_ = utf8_length + length;
+      state_ = kInitialState;
+    }
+
+    void VisitTwoByteString(const uint16_t* chars, int length) {
       int utf8_length = 0;
       int last_character = unibrow::Utf16::kNoPreviousCharacter;
       for (int i = 0; i < length; i++) {
         uint16_t c = chars[i];
         utf8_length += unibrow::Utf8::Length(c, last_character);
-        if (sizeof(Char) > 1) {
-          last_character = c;
-        }
+        last_character = c;
       }
       utf8_length_ = utf8_length;
-    }
-
-    void VisitOneByteString(const uint8_t* chars, int length) {
-      Visit(chars, length);
-      state_ = kInitialState;
-    }
-
-    void VisitTwoByteString(const uint16_t* chars, int length) {
-      Visit(chars, length);
       uint8_t state = 0;
       if (unibrow::Utf16::IsTrailSurrogate(chars[0])) {
         state |= kStartsWithTrailingSurrogate;
@@ -4132,32 +4140,30 @@
       if (right_as_cons == NULL) {
         total_length += leaf_length;
         MergeLeafRight(&total_length, &state, right_leaf_state);
-        // Terminal node.
-        if (left_as_cons == NULL) {
+        if (left_as_cons != NULL) {
+          // 1 Leaf node. Descend in place.
+          current = left_as_cons;
+          continue;
+        } else {
+          // Terminal node.
           MergeTerminal(&total_length, state, state_out);
           return total_length;
         }
-      } else if (left_as_cons != NULL) {
-        // Both strings are ConsStrings.
-        // Recurse on smallest.
-        if (left->length() < right->length()) {
-          total_length += Calculate(left_as_cons, &left_leaf_state);
-          MergeLeafLeft(&total_length, &state, left_leaf_state);
-          current = right_as_cons;
-          continue;
-        } else {
-          total_length += Calculate(right_as_cons, &right_leaf_state);
-          MergeLeafRight(&total_length, &state, right_leaf_state);
-          current = left_as_cons;
-          continue;
-        }
-      }
-      // 1 leaf node. Do in place descent.
-      if (left_as_cons != NULL) {
-        current = left_as_cons;
-      } else {
-        ASSERT(right_as_cons != NULL);
+      } else if (left_as_cons == NULL) {
+        // 1 Leaf node. Descend in place.
         current = right_as_cons;
+        continue;
+      }
+      // Both strings are ConsStrings.
+      // Recurse on smallest.
+      if (left->length() < right->length()) {
+        total_length += Calculate(left_as_cons, &left_leaf_state);
+        MergeLeafLeft(&total_length, &state, left_leaf_state);
+        current = right_as_cons;
+      } else {
+        total_length += Calculate(right_as_cons, &right_leaf_state);
+        MergeLeafRight(&total_length, &state, right_leaf_state);
+        current = left_as_cons;
       }
     }
     UNREACHABLE();
@@ -4267,7 +4273,7 @@
       if (sizeof(Char) == 1) {
         for (; i < fast_length; i++) {
           buffer +=
-              Utf8::Encode(buffer, *chars++, Utf16::kNoPreviousCharacter);
+              Utf8::EncodeOneByte(buffer, static_cast<uint8_t>(*chars++));
           ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_);
         }
       } else {
@@ -5783,14 +5789,21 @@
 }
 
 
+intptr_t Isolate::AdjustAmountOfExternalAllocatedMemory(
+    intptr_t change_in_bytes) {
+  i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
+  return heap->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
+}
+
+
 intptr_t V8::AdjustAmountOfExternalAllocatedMemory(intptr_t change_in_bytes) {
   i::Isolate* isolate = i::Isolate::UncheckedCurrent();
   if (isolate == NULL || !isolate->IsInitialized() ||
       IsDeadCheck(isolate, "v8::V8::AdjustAmountOfExternalAllocatedMemory()")) {
     return 0;
   }
-  return isolate->heap()->AdjustAmountOfExternalAllocatedMemory(
-      change_in_bytes);
+  Isolate* isolate_ext = reinterpret_cast<Isolate*>(isolate);
+  return isolate_ext->AdjustAmountOfExternalAllocatedMemory(change_in_bytes);
 }
 
 
@@ -6314,7 +6327,7 @@
   if (!isolate->IsInitialized()) return Local<Value>();
   ON_BAILOUT(isolate, "v8::Debug::GetMirror()", return Local<Value>());
   ENTER_V8(isolate);
-  v8::HandleScope scope;
+  v8::HandleScope scope(reinterpret_cast<Isolate*>(isolate));
   i::Debug* isolate_debug = isolate->debug();
   isolate_debug->Load();
   i::Handle<i::JSObject> debug(isolate_debug->debug_context()->global_object());
diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h
index 85a523d..123013b 100644
--- a/src/arm/assembler-arm-inl.h
+++ b/src/arm/assembler-arm-inl.h
@@ -107,13 +107,13 @@
 
 
 Address RelocInfo::target_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
   return Assembler::target_address_at(pc_);
 }
 
 
 Address RelocInfo::target_address_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
+  ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
                               || rmode_ == EMBEDDED_OBJECT
                               || rmode_ == EXTERNAL_REFERENCE);
   return reinterpret_cast<Address>(Assembler::target_pointer_address_at(pc_));
@@ -126,7 +126,7 @@
 
 
 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
   Assembler::set_target_address_at(pc_, target);
   if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
     Object* target_code = Code::GetCodeFromTargetAddress(target);
@@ -321,7 +321,7 @@
              Isolate::Current()->debug()->has_break_points()) {
     visitor->VisitDebugTarget(this);
 #endif
-  } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+  } else if (RelocInfo::IsRuntimeEntry(mode)) {
     visitor->VisitRuntimeEntry(this);
   }
 }
@@ -348,7 +348,7 @@
               IsPatchedDebugBreakSlotSequence()))) {
     StaticVisitor::VisitDebugTarget(heap, this);
 #endif
-  } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+  } else if (RelocInfo::IsRuntimeEntry(mode)) {
     StaticVisitor::VisitRuntimeEntry(this);
   }
 }
diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc
index 142787b..2946b35 100644
--- a/src/arm/builtins-arm.cc
+++ b/src/arm/builtins-arm.cc
@@ -124,12 +124,7 @@
   if (initial_capacity > 0) {
     size += FixedArray::SizeFor(initial_capacity);
   }
-  __ AllocateInNewSpace(size,
-                        result,
-                        scratch2,
-                        scratch3,
-                        gc_required,
-                        TAG_OBJECT);
+  __ Allocate(size, result, scratch2, scratch3, gc_required, TAG_OBJECT);
 
   // Allocated the JSArray. Now initialize the fields except for the elements
   // array.
@@ -653,12 +648,12 @@
   // -----------------------------------
 
   Label gc_required;
-  __ AllocateInNewSpace(JSValue::kSize,
-                        r0,  // Result.
-                        r3,  // Scratch.
-                        r4,  // Scratch.
-                        &gc_required,
-                        TAG_OBJECT);
+  __ Allocate(JSValue::kSize,
+              r0,  // Result.
+              r3,  // Scratch.
+              r4,  // Scratch.
+              &gc_required,
+              TAG_OBJECT);
 
   // Initialising the String Object.
   Register map = r3;
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc
index f2f6408..b1ffaea 100644
--- a/src/arm/code-stubs-arm.cc
+++ b/src/arm/code-stubs-arm.cc
@@ -166,12 +166,7 @@
   __ pop(r3);
 
   // Attempt to allocate new JSFunction in new space.
-  __ AllocateInNewSpace(JSFunction::kSize,
-                        r0,
-                        r1,
-                        r2,
-                        &gc,
-                        TAG_OBJECT);
+  __ Allocate(JSFunction::kSize, r0, r1, r2, &gc, TAG_OBJECT);
 
   __ IncrementCounter(counters->fast_new_closure_total(), 1, r6, r7);
 
@@ -298,12 +293,7 @@
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
 
   // Attempt to allocate the context in new space.
-  __ AllocateInNewSpace(FixedArray::SizeFor(length),
-                        r0,
-                        r1,
-                        r2,
-                        &gc,
-                        TAG_OBJECT);
+  __ Allocate(FixedArray::SizeFor(length), r0, r1, r2, &gc, TAG_OBJECT);
 
   // Load the function from the stack.
   __ ldr(r3, MemOperand(sp, 0));
@@ -348,8 +338,7 @@
   // Try to allocate the context in new space.
   Label gc;
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-  __ AllocateInNewSpace(FixedArray::SizeFor(length),
-                        r0, r1, r2, &gc, TAG_OBJECT);
+  __ Allocate(FixedArray::SizeFor(length), r0, r1, r2, &gc, TAG_OBJECT);
 
   // Load the function from the stack.
   __ ldr(r3, MemOperand(sp, 0));
@@ -435,7 +424,7 @@
   if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
     flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
   }
-  __ AllocateInNewSpace(size, r0, r1, r2, fail, flags);
+  __ Allocate(size, r0, r1, r2, fail, flags);
 
   if (allocation_site_mode == TRACK_ALLOCATION_SITE) {
     __ mov(r2, Operand(Handle<Map>(masm->isolate()->heap()->
@@ -4513,7 +4502,7 @@
 
   StubCompiler::GenerateLoadArrayLength(masm, receiver, r3, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4542,7 +4531,7 @@
 
   StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, r3, r4, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4573,7 +4562,7 @@
                                          support_wrapper_);
 
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4643,7 +4632,7 @@
 
   __ bind(&miss);
 
-  StubCompiler::GenerateStoreMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
index eb1f988..1df1649 100644
--- a/src/arm/full-codegen-arm.cc
+++ b/src/arm/full-codegen-arm.cc
@@ -1547,7 +1547,7 @@
   __ bind(&materialized);
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc
index e10068f..7272f54 100644
--- a/src/arm/lithium-arm.cc
+++ b/src/arm/lithium-arm.cc
@@ -290,6 +290,13 @@
 }
 
 
+void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
+  stream->Add(" = ");
+  base_object()->PrintTo(stream);
+  stream->Add(" + %d", offset());
+}
+
+
 void LCallConstantFunction::PrintDataTo(StringStream* stream) {
   stream->Add("#%d / ", arity());
 }
@@ -668,8 +675,12 @@
 LUnallocated* LChunkBuilder::TempRegister() {
   LUnallocated* operand =
       new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
-  operand->set_virtual_register(allocator_->GetVirtualRegister());
-  if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+  int vreg = allocator_->GetVirtualRegister();
+  if (!allocator_->AllocationOk()) {
+    Abort("Out of virtual registers while trying to allocate temp register.");
+    return NULL;
+  }
+  operand->set_virtual_register(vreg);
   return operand;
 }
 
@@ -928,7 +939,7 @@
 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
   HValue* value = instr->value();
   if (value->EmitAtUses()) {
-    HBasicBlock* successor = HConstant::cast(value)->ToBoolean()
+    HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
         ? instr->FirstSuccessor()
         : instr->SecondSuccessor();
     return new(zone()) LGoto(successor->block_id());
@@ -1017,6 +1028,15 @@
 }
 
 
+LInstruction* LChunkBuilder::DoInnerAllocatedObject(
+    HInnerAllocatedObject* inner_object) {
+  LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
+  LInnerAllocatedObject* result =
+    new(zone()) LInnerAllocatedObject(base_object);
+  return DefineAsRegister(result);
+}
+
+
 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
   return instr->HasNoUses()
       ? NULL
diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h
index ca8b493..f49e8ce 100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -191,7 +191,8 @@
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
   V(WrapReceiver)                               \
-  V(Drop)
+  V(Drop)                                       \
+  V(InnerAllocatedObject)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -1655,6 +1656,22 @@
 };
 
 
+class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
+ public:
+  explicit LInnerAllocatedObject(LOperand* base_object) {
+    inputs_[0] = base_object;
+  }
+
+  LOperand* base_object() { return inputs_[0]; }
+  int offset() { return hydrogen()->offset(); }
+
+  virtual void PrintDataTo(StringStream* stream);
+
+  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
+  DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
+};
+
+
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index 6e2fc17..e8f96e4 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -4341,6 +4341,13 @@
 }
 
 
+void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
+  Register result = ToRegister(instr->result());
+  Register base = ToRegister(instr->base_object());
+  __ add(result, base, Operand(instr->offset()));
+}
+
+
 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   Register object = ToRegister(instr->object());
   Register value = ToRegister(instr->value());
@@ -5581,12 +5588,8 @@
   // the constructor's prototype changes, but instance size and property
   // counts remain unchanged (if slack tracking finished).
   ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
-  __ AllocateInNewSpace(instance_size,
-                        result,
-                        scratch,
-                        scratch2,
-                        deferred->entry(),
-                        TAG_OBJECT);
+  __ Allocate(instance_size, result, scratch, scratch2, deferred->entry(),
+              TAG_OBJECT);
 
   __ bind(deferred->exit());
   if (FLAG_debug_code) {
@@ -5661,12 +5664,10 @@
   }
   if (instr->size()->IsConstantOperand()) {
     int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
-    __ AllocateInNewSpace(size,
-                          result,
-                          scratch,
-                          scratch2,
-                          deferred->entry(),
-                          flags);
+    if (instr->hydrogen()->CanAllocateInOldPointerSpace()) {
+      flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_POINTER_SPACE);
+    }
+    __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags);
   } else {
     Register size = ToRegister(instr->size());
     __ AllocateInNewSpace(size,
@@ -5899,7 +5900,7 @@
   // Allocate all objects that are part of the literal in one big
   // allocation. This avoids multiple limit checks.
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
@@ -5981,7 +5982,7 @@
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
 
-  __ AllocateInNewSpace(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc
index 1542447..e0e77cf 100644
--- a/src/arm/macro-assembler-arm.cc
+++ b/src/arm/macro-assembler-arm.cc
@@ -1564,12 +1564,12 @@
 }
 
 
-void MacroAssembler::AllocateInNewSpace(int object_size,
-                                        Register result,
-                                        Register scratch1,
-                                        Register scratch2,
-                                        Label* gc_required,
-                                        AllocationFlags flags) {
+void MacroAssembler::Allocate(int object_size,
+                              Register result,
+                              Register scratch1,
+                              Register scratch2,
+                              Label* gc_required,
+                              AllocationFlags flags) {
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -1597,21 +1597,22 @@
   // The values must be adjacent in memory to allow the use of LDM.
   // Also, assert that the registers are numbered such that the values
   // are loaded in the correct order.
-  ExternalReference new_space_allocation_top =
-      ExternalReference::new_space_allocation_top_address(isolate());
-  ExternalReference new_space_allocation_limit =
-      ExternalReference::new_space_allocation_limit_address(isolate());
+  ExternalReference allocation_top =
+      AllocationUtils::GetAllocationTopReference(isolate(), flags);
+  ExternalReference allocation_limit =
+      AllocationUtils::GetAllocationLimitReference(isolate(), flags);
+
   intptr_t top   =
-      reinterpret_cast<intptr_t>(new_space_allocation_top.address());
+      reinterpret_cast<intptr_t>(allocation_top.address());
   intptr_t limit =
-      reinterpret_cast<intptr_t>(new_space_allocation_limit.address());
+      reinterpret_cast<intptr_t>(allocation_limit.address());
   ASSERT((limit - top) == kPointerSize);
   ASSERT(result.code() < ip.code());
 
   // Set up allocation top address and object size registers.
   Register topaddr = scratch1;
   Register obj_size_reg = scratch2;
-  mov(topaddr, Operand(new_space_allocation_top));
+  mov(topaddr, Operand(allocation_top));
   Operand obj_size_operand = Operand(object_size);
   if (!obj_size_operand.is_single_instruction(this)) {
     // We are about to steal IP, so we need to load this value first
@@ -1639,6 +1640,7 @@
   if ((flags & DOUBLE_ALIGNMENT) != 0) {
     // Align the next allocation. Storing the filler map without checking top is
     // always safe because the limit of the heap is always aligned.
+    ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
     ASSERT(kPointerAlignment * 2 == kDoubleAlignment);
     and_(scratch2, result, Operand(kDoubleAlignmentMask), SetCC);
     Label aligned;
@@ -1675,6 +1677,7 @@
                                         Register scratch2,
                                         Label* gc_required,
                                         AllocationFlags flags) {
+  ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -1858,12 +1861,8 @@
                                                Register scratch1,
                                                Register scratch2,
                                                Label* gc_required) {
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   InitializeNewString(result,
                       length,
@@ -1878,12 +1877,8 @@
                                              Register scratch1,
                                              Register scratch2,
                                              Label* gc_required) {
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   InitializeNewString(result,
                       length,
@@ -1898,12 +1893,8 @@
                                                  Register scratch1,
                                                  Register scratch2,
                                                  Label* gc_required) {
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   InitializeNewString(result,
                       length,
@@ -1918,12 +1909,8 @@
                                                Register scratch1,
                                                Register scratch2,
                                                Label* gc_required) {
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   InitializeNewString(result,
                       length,
@@ -2238,7 +2225,8 @@
 
 
 void MacroAssembler::TailCallStub(CodeStub* stub, Condition cond) {
-  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
+  ASSERT(allow_stub_calls_ ||
+         stub->CompilingCallsToThisStubIsGCSafe(isolate()));
   Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, cond);
 }
 
@@ -2348,7 +2336,7 @@
 
 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate());
 }
 
 
@@ -2544,7 +2532,15 @@
          !scratch.is(input_low));
   ASSERT(!double_input.is(double_scratch));
 
-  Label overflow, out_of_range, negate, done;
+  Label out_of_range, negate, done;
+
+  vcvt_s32_f64(double_scratch.low(), double_input);
+  vmov(result, double_scratch.low());
+
+  // If result is not saturated (0x7fffffff or 0x80000000), we are done.
+  sub(scratch, result, Operand(1));
+  cmp(scratch, Operand(0x7ffffffe));
+  b(lt, &done);
 
   vmov(input_low, input_high, double_input);
   Ubfx(scratch, input_high,
@@ -2552,20 +2548,9 @@
   // Load scratch with exponent - 1. This is faster than loading
   // with exponent because Bias + 1 = 1024 which is an *ARM* immediate value.
   sub(scratch, scratch, Operand(HeapNumber::kExponentBias + 1));
-  // Compare exponent with 31 (compare exponent - 1 with 30).
-  cmp(scratch, Operand(30));
-  b(ge, &overflow);
-  // Exponent is less than 31 so vcvt will never saturate.
-  // So, just return the result.
-  vcvt_s32_f64(double_scratch.low(), double_input);
-  vmov(result, double_scratch.low());
-  b(&done);
-
-  bind(&overflow);
   // If exponent is greater than or equal to 84, the 32 less significant
   // bits are 0s (2^84 = 1, 52 significant bits, 32 uncoded bits),
   // the result is 0.
-  // This test also catch Nan and infinities which also return 0.
   // Compare exponent with 84 (compare exponent - 1 with 83).
   cmp(scratch, Operand(83));
   b(ge, &out_of_range);
@@ -3231,13 +3216,8 @@
                                         TaggingMode tagging_mode) {
   // Allocate an object in the heap for the heap number and tag it as a heap
   // object.
-  AllocateInNewSpace(HeapNumber::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     tagging_mode == TAG_RESULT ? TAG_OBJECT :
-                                                  NO_ALLOCATION_FLAGS);
+  Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required,
+           tagging_mode == TAG_RESULT ? TAG_OBJECT : NO_ALLOCATION_FLAGS);
 
   // Store heap number map in the allocated object.
   AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h
index 05ede68..5cbe995 100644
--- a/src/arm/macro-assembler-arm.h
+++ b/src/arm/macro-assembler-arm.h
@@ -665,19 +665,20 @@
   // ---------------------------------------------------------------------------
   // Allocation support
 
-  // Allocate an object in new space. The object_size is specified
-  // either in bytes or in words if the allocation flag SIZE_IN_WORDS
-  // is passed. If the new space is exhausted control continues at the
-  // gc_required label. The allocated object is returned in result. If
-  // the flag tag_allocated_object is true the result is tagged as as
-  // a heap object. All registers are clobbered also when control
-  // continues at the gc_required label.
-  void AllocateInNewSpace(int object_size,
-                          Register result,
-                          Register scratch1,
-                          Register scratch2,
-                          Label* gc_required,
-                          AllocationFlags flags);
+  // Allocate an object in new space or old pointer space. The object_size is
+  // specified either in bytes or in words if the allocation flag SIZE_IN_WORDS
+  // is passed. If the space is exhausted control continues at the gc_required
+  // label. The allocated object is returned in result. If the flag
+  // tag_allocated_object is true the result is tagged as as a heap object.
+  // All registers are clobbered also when control continues at the gc_required
+  // label.
+  void Allocate(int object_size,
+                Register result,
+                Register scratch1,
+                Register scratch2,
+                Label* gc_required,
+                AllocationFlags flags);
+
   void AllocateInNewSpace(Register object_size,
                           Register result,
                           Register scratch1,
diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc
index 7e6c344..0cb80c0 100644
--- a/src/arm/regexp-macro-assembler-arm.cc
+++ b/src/arm/regexp-macro-assembler-arm.cc
@@ -337,9 +337,6 @@
     __ b(ne, &fail);
     __ sub(r3, r3, Operand('a'));
     __ cmp(r3, Operand('z' - 'a'));  // Is r3 a lowercase letter?
-#ifndef ENABLE_LATIN_1
-    __ b(hi, &fail);
-#else
     __ b(ls, &loop_check);  // In range 'a'-'z'.
     // Latin-1: Check for values in range [224,254] but not 247.
     __ sub(r3, r3, Operand(224 - 'a'));
@@ -347,7 +344,6 @@
     __ b(hi, &fail);  // Weren't Latin-1 letters.
     __ cmp(r3, Operand(247 - 224));  // Check for 247.
     __ b(eq, &fail);
-#endif
 
     __ bind(&loop_check);
     __ cmp(r0, r1);
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index ac9b5ec..e3d27f1 100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -320,19 +320,6 @@
 }
 
 
-// Load a fast property out of a holder object (src). In-object properties
-// are loaded directly otherwise the property is loaded from the properties
-// fixed array.
-void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
-                                            Register dst,
-                                            Register src,
-                                            Handle<JSObject> holder,
-                                            PropertyIndex index) {
-  DoGenerateFastPropertyLoad(
-      masm, dst, src, index.is_inobject(holder), index.translate(holder));
-}
-
-
 void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm,
                                               Register dst,
                                               Register src,
@@ -446,9 +433,11 @@
                                       Handle<Name> name,
                                       Register receiver_reg,
                                       Register name_reg,
+                                      Register value_reg,
                                       Register scratch1,
                                       Register scratch2,
-                                      Label* miss_label) {
+                                      Label* miss_label,
+                                      Label* miss_restore_name) {
   // r0 : value
   Label exit;
 
@@ -485,17 +474,8 @@
         holder = JSObject::cast(holder->GetPrototype());
       } while (holder->GetPrototype()->IsJSObject());
     }
-    // We need an extra register, push
-    __ push(name_reg);
-    Label miss_pop, done_check;
     CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
-                    scratch1, scratch2, name, &miss_pop);
-    __ jmp(&done_check);
-    __ bind(&miss_pop);
-    __ pop(name_reg);
-    __ jmp(miss_label);
-    __ bind(&done_check);
-    __ pop(name_reg);
+                    scratch1, scratch2, name, miss_restore_name);
   }
 
   // Stub never generated for non-global objects that require access
@@ -542,14 +522,14 @@
   if (index < 0) {
     // Set the property straight into the object.
     int offset = object->map()->instance_size() + (index * kPointerSize);
-    __ str(r0, FieldMemOperand(receiver_reg, offset));
+    __ str(value_reg, FieldMemOperand(receiver_reg, offset));
 
     // Skip updating write barrier if storing a smi.
-    __ JumpIfSmi(r0, &exit);
+    __ JumpIfSmi(value_reg, &exit);
 
     // Update the write barrier for the array address.
     // Pass the now unused name_reg as a scratch register.
-    __ mov(name_reg, r0);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(receiver_reg,
                         offset,
                         name_reg,
@@ -562,14 +542,14 @@
     // Get the properties array
     __ ldr(scratch1,
            FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset));
-    __ str(r0, FieldMemOperand(scratch1, offset));
+    __ str(value_reg, FieldMemOperand(scratch1, offset));
 
     // Skip updating write barrier if storing a smi.
-    __ JumpIfSmi(r0, &exit);
+    __ JumpIfSmi(value_reg, &exit);
 
     // Update the write barrier for the array address.
     // Ok to clobber receiver_reg and name_reg, since we return.
-    __ mov(name_reg, r0);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(scratch1,
                         offset,
                         name_reg,
@@ -579,26 +559,19 @@
   }
 
   // Return the value (register r0).
+  ASSERT(value_reg.is(r0));
   __ bind(&exit);
   __ Ret();
 }
 
 
-void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
-  Handle<Code> code = (kind == Code::LOAD_IC)
-      ? masm->isolate()->builtins()->LoadIC_Miss()
-      : masm->isolate()->builtins()->KeyedLoadIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
-  Handle<Code> code = (kind == Code::STORE_IC)
-      ? masm->isolate()->builtins()->StoreIC_Miss()
-      : masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
+void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
+                                                Label* label,
+                                                Handle<Name> name) {
+  if (!label->is_unused()) {
+    __ bind(label);
+    __ mov(this->name(), Operand(name));
+  }
 }
 
 
@@ -1063,15 +1036,15 @@
 }
 
 
-#undef __
-#define __ ACCESS_MASM(masm())
-
-
-void StubCompiler::GenerateTailCall(Handle<Code> code) {
+void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
   __ Jump(code, RelocInfo::CODE_TARGET);
 }
 
 
+#undef __
+#define __ ACCESS_MASM(masm())
+
+
 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
                                        Register object_reg,
                                        Handle<JSObject> holder,
@@ -1190,7 +1163,7 @@
   if (!miss->is_unused()) {
     __ b(success);
     __ bind(miss);
-    GenerateLoadMiss(masm(), kind());
+    TailCallBuiltin(masm(), MissBuiltin(kind()));
   }
 }
 
@@ -2599,58 +2572,23 @@
 }
 
 
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                  int index,
-                                                  Handle<Map> transition,
-                                                  Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : receiver
-  //  -- r2    : name
-  //  -- lr    : return address
-  // -----------------------------------
-  Label miss;
-
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     r1, r2, r3, r4,
-                     &miss);
-  __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreCallback(
     Handle<Name> name,
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<JSObject> holder,
     Handle<ExecutableAccessorInfo> callback) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : receiver
-  //  -- r2    : name
-  //  -- lr    : return address
-  // -----------------------------------
   Label miss;
   // Check that the maps haven't changed.
-  __ JumpIfSmi(r1, &miss);
-  CheckPrototypes(receiver, r1, holder, r3, r4, r5, name, &miss);
+  __ JumpIfSmi(receiver(), &miss);
+  CheckPrototypes(object, receiver(), holder,
+                  scratch1(), scratch2(), scratch3(), name, &miss);
 
   // Stub never generated for non-global objects that require access checks.
   ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
 
-  __ push(r1);  // receiver
+  __ push(receiver());  // receiver
   __ mov(ip, Operand(callback));  // callback info
-  __ Push(ip, r2, r0);
+  __ Push(ip, this->name(), value());
 
   // Do tail-call to the runtime system.
   ExternalReference store_callback_property =
@@ -2660,11 +2598,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
+  return GetICCode(kind(), Code::CALLBACKS, name);
 }
 
 
@@ -2713,62 +2650,28 @@
 #define __ ACCESS_MASM(masm())
 
 
-Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
-    Handle<Name> name,
-    Handle<JSObject> receiver,
-    Handle<JSObject> holder,
-    Handle<JSFunction> setter) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : receiver
-  //  -- r2    : name
-  //  -- lr    : return address
-  // -----------------------------------
-  Label miss;
-
-  // Check that the maps haven't changed.
-  __ JumpIfSmi(r1, &miss);
-  CheckPrototypes(receiver, r1, holder, r3, r4, r5, name, &miss);
-
-  GenerateStoreViaSetter(masm(), setter);
-
-  __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : receiver
-  //  -- r2    : name
-  //  -- lr    : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the object hasn't changed.
-  __ CheckMap(r1, r3, Handle<Map>(receiver->map()), &miss,
+  __ CheckMap(receiver(), scratch1(), Handle<Map>(object->map()), &miss,
               DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS);
 
   // Perform global security token check if needed.
-  if (receiver->IsJSGlobalProxy()) {
-    __ CheckAccessGlobalProxy(r1, r3, &miss);
+  if (object->IsJSGlobalProxy()) {
+    __ CheckAccessGlobalProxy(receiver(), scratch1(), &miss);
   }
 
   // Stub is never generated for non-global objects that require access
   // checks.
-  ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded());
+  ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
 
-  __ Push(r1, r2, r0);  // Receiver, name, value.
+  __ Push(receiver(), this->name(), value());
 
-  __ mov(r0, Operand(Smi::FromInt(strict_mode_)));
-  __ push(r0);  // strict mode
+  __ mov(scratch1(), Operand(Smi::FromInt(strict_mode())));
+  __ push(scratch1());  // strict mode
 
   // Do tail-call to the runtime system.
   ExternalReference store_ic_property =
@@ -2778,11 +2681,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::INTERCEPTOR, name);
+  return GetICCode(kind(), Code::INTERCEPTOR, name);
 }
 
 
@@ -2790,45 +2692,42 @@
     Handle<GlobalObject> object,
     Handle<JSGlobalPropertyCell> cell,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : receiver
-  //  -- r2    : name
-  //  -- lr    : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the global has not changed.
-  __ ldr(r3, FieldMemOperand(r1, HeapObject::kMapOffset));
-  __ cmp(r3, Operand(Handle<Map>(object->map())));
+  __ ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
+  __ cmp(scratch1(), Operand(Handle<Map>(object->map())));
   __ b(ne, &miss);
 
   // Check that the value in the cell is not the hole. If it is, this
   // cell could have been deleted and reintroducing the global needs
   // to update the property details in the property dictionary of the
   // global object. We bail out to the runtime system to do that.
-  __ mov(r4, Operand(cell));
-  __ LoadRoot(r5, Heap::kTheHoleValueRootIndex);
-  __ ldr(r6, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset));
-  __ cmp(r5, r6);
+  __ mov(scratch1(), Operand(cell));
+  __ LoadRoot(scratch2(), Heap::kTheHoleValueRootIndex);
+  __ ldr(scratch3(),
+         FieldMemOperand(scratch1(), JSGlobalPropertyCell::kValueOffset));
+  __ cmp(scratch3(), scratch2());
   __ b(eq, &miss);
 
   // Store the value in the cell.
-  __ str(r0, FieldMemOperand(r4, JSGlobalPropertyCell::kValueOffset));
+  __ str(value(),
+         FieldMemOperand(scratch1(), JSGlobalPropertyCell::kValueOffset));
   // Cells are always rescanned, so no write barrier here.
 
   Counters* counters = masm()->isolate()->counters();
-  __ IncrementCounter(counters->named_store_global_inline(), 1, r4, r3);
+  __ IncrementCounter(
+      counters->named_store_global_inline(), 1, scratch1(), scratch2());
   __ Ret();
 
   // Handle store cache miss.
   __ bind(&miss);
-  __ IncrementCounter(counters->named_store_global_inline_miss(), 1, r4, r3);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  __ IncrementCounter(
+      counters->named_store_global_inline_miss(), 1, scratch1(), scratch2());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, name);
+  return GetICCode(kind(), Code::NORMAL, name);
 }
 
 
@@ -2866,6 +2765,20 @@
 }
 
 
+Register* StoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { r1, r2, r0, r3, r4, r5 };
+  return registers;
+}
+
+
+Register* KeyedStoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { r2, r1, r0, r3, r4, r5 };
+  return registers;
+}
+
+
 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
                                               Register name_reg,
                                               Label* miss) {
@@ -2874,6 +2787,14 @@
 }
 
 
+void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name,
+                                               Register name_reg,
+                                               Label* miss) {
+  __ cmp(name_reg, Operand(name));
+  __ b(ne, miss);
+}
+
+
 #undef __
 #define __ ACCESS_MASM(masm)
 
@@ -2948,34 +2869,6 @@
 }
 
 
-Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- lr    : return address
-  //  -- r0    : key
-  //  -- r1    : receiver
-  // -----------------------------------
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  if (receiver_map->has_fast_elements() ||
-      receiver_map->has_external_array_elements()) {
-    Handle<Code> stub = KeyedLoadFastElementStub(
-        receiver_map->instance_type() == JS_ARRAY_TYPE,
-        elements_kind).GetCode(isolate());
-    __ DispatchMap(r1, r2, receiver_map, stub, DO_SMI_CHECK);
-  } else {
-    Handle<Code> stub =
-        KeyedLoadDictionaryElementStub().GetCode(isolate());
-    __ DispatchMap(r1, r2, receiver_map, stub, DO_SMI_CHECK);
-  }
-
-  Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
-}
-
-
 Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC(
     MapHandleList* receiver_maps,
     CodeHandleList* handlers,
@@ -3000,7 +2893,7 @@
   }
 
   __ bind(&miss);
-  GenerateLoadMiss(masm(), kind());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   InlineCacheState state =
@@ -3009,109 +2902,35 @@
 }
 
 
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                       int index,
-                                                       Handle<Map> transition,
-                                                       Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : name
-  //  -- r2    : receiver
-  //  -- lr    : return address
-  // -----------------------------------
-  Label miss;
-
-  Counters* counters = masm()->isolate()->counters();
-  __ IncrementCounter(counters->keyed_store_field(), 1, r3, r4);
-
-  // Check that the name has not changed.
-  __ cmp(r1, Operand(name));
-  __ b(ne, &miss);
-
-  // r3 is used as scratch register. r1 and r2 keep their values if a jump to
-  // the miss label is generated.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     r2, r1, r3, r4,
-                     &miss);
-  __ bind(&miss);
-
-  __ DecrementCounter(counters->keyed_store_field(), 1, r3, r4);
-  Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : key
-  //  -- r2    : receiver
-  //  -- lr    : return address
-  //  -- r3    : scratch
-  // -----------------------------------
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
-  Handle<Code> stub =
-      KeyedStoreElementStub(is_js_array,
-                            elements_kind,
-                            store_mode_).GetCode(isolate());
-
-  __ DispatchMap(r2, r3, receiver_map, stub, DO_SMI_CHECK);
-
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string());
-}
-
-
 Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
     MapHandleList* receiver_maps,
     CodeHandleList* handler_stubs,
     MapHandleList* transitioned_maps) {
-  // ----------- S t a t e -------------
-  //  -- r0    : value
-  //  -- r1    : key
-  //  -- r2    : receiver
-  //  -- lr    : return address
-  //  -- r3    : scratch
-  // -----------------------------------
   Label miss;
-  __ JumpIfSmi(r2, &miss);
+  __ JumpIfSmi(receiver(), &miss);
 
   int receiver_count = receiver_maps->length();
-  __ ldr(r3, FieldMemOperand(r2, HeapObject::kMapOffset));
+  __ ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset));
   for (int i = 0; i < receiver_count; ++i) {
     __ mov(ip, Operand(receiver_maps->at(i)));
-    __ cmp(r3, ip);
+    __ cmp(scratch1(), ip);
     if (transitioned_maps->at(i).is_null()) {
       __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq);
     } else {
       Label next_map;
       __ b(ne, &next_map);
-      __ mov(r3, Operand(transitioned_maps->at(i)));
+      __ mov(transition_map(), Operand(transitioned_maps->at(i)));
       __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al);
       __ bind(&next_map);
     }
   }
 
   __ bind(&miss);
-  Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
+  return GetICCode(
+      kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
 }
 
 
@@ -3292,9 +3111,7 @@
   //  -- r0     : key
   //  -- r1     : receiver
   // -----------------------------------
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_Slow();
-  __ Jump(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow);
 
   // Miss case, call the runtime.
   __ bind(&miss_force_generic);
@@ -3304,10 +3121,7 @@
   //  -- r0     : key
   //  -- r1     : receiver
   // -----------------------------------
-
-  Handle<Code> miss_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
 }
 
 
@@ -3699,9 +3513,7 @@
   //  -- r0     : key
   //  -- r1     : receiver
   // -----------------------------------
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedStoreIC_Slow();
-  __ Jump(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
 
   // Miss case, call the runtime.
   __ bind(&miss_force_generic);
@@ -3711,10 +3523,7 @@
   //  -- r0     : key
   //  -- r1     : receiver
   // -----------------------------------
-
-  Handle<Code> miss_ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 }
 
 
@@ -3807,13 +3616,10 @@
   __ Ret();
 
   __ bind(&miss_force_generic);
-  Handle<Code> ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -3833,8 +3639,7 @@
     __ b(ne, &check_capacity);
 
     int size = FixedArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, elements_reg, scratch, scratch2, &slow,
-                          TAG_OBJECT);
+    __ Allocate(size, elements_reg, scratch, scratch2, &slow, TAG_OBJECT);
 
     __ LoadRoot(scratch, Heap::kFixedArrayMapRootIndex);
     __ str(scratch, FieldMemOperand(elements_reg, JSObject::kMapOffset));
@@ -3878,8 +3683,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ Jump(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
@@ -3953,13 +3757,10 @@
 
   // Handle store cache miss, replacing the ic with the generic stub.
   __ bind(&miss_force_generic);
-  Handle<Code> ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -3987,8 +3788,7 @@
     __ b(ne, &check_capacity);
 
     int size = FixedDoubleArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, elements_reg, scratch1, scratch2, &slow,
-                          TAG_OBJECT);
+    __ Allocate(size, elements_reg, scratch1, scratch2, &slow, TAG_OBJECT);
 
     // Initialize the new FixedDoubleArray.
     __ LoadRoot(scratch1, Heap::kFixedDoubleArrayMapRootIndex);
@@ -4044,8 +3844,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ Jump(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
diff --git a/src/assembler.cc b/src/assembler.cc
index 8d8208d..fc96662 100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -811,7 +811,7 @@
     }
   } else if (IsPosition(rmode_)) {
     PrintF(out, "  (%" V8_PTR_PREFIX "d)", data());
-  } else if (rmode_ == RelocInfo::RUNTIME_ENTRY &&
+  } else if (IsRuntimeEntry(rmode_) &&
              Isolate::Current()->deoptimizer_data() != NULL) {
     // Depotimization bailouts are stored as runtime entries.
     int id = Deoptimizer::GetDeoptimizationId(
@@ -1188,6 +1188,20 @@
 }
 
 
+ExternalReference ExternalReference::old_pointer_space_allocation_top_address(
+    Isolate* isolate) {
+  return ExternalReference(
+      isolate->heap()->OldPointerSpaceAllocationTopAddress());
+}
+
+
+ExternalReference ExternalReference::old_pointer_space_allocation_limit_address(
+    Isolate* isolate) {
+  return ExternalReference(
+      isolate->heap()->OldPointerSpaceAllocationLimitAddress());
+}
+
+
 ExternalReference ExternalReference::handle_scope_level_address(
     Isolate* isolate) {
   return ExternalReference(HandleScope::current_level_address(isolate));
diff --git a/src/assembler.h b/src/assembler.h
index f5ae611..4a67ce3 100644
--- a/src/assembler.h
+++ b/src/assembler.h
@@ -373,7 +373,7 @@
 
   // Read/modify the code target in the branch/call instruction
   // this relocation applies to;
-  // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
+  // can only be called if IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)
   INLINE(Address target_address());
   INLINE(void set_target_address(Address target,
                                  WriteBarrierMode mode = UPDATE_WRITE_BARRIER));
@@ -749,6 +749,10 @@
   // Used for fast allocation in generated code.
   static ExternalReference new_space_allocation_top_address(Isolate* isolate);
   static ExternalReference new_space_allocation_limit_address(Isolate* isolate);
+  static ExternalReference old_pointer_space_allocation_top_address(
+      Isolate* isolate);
+  static ExternalReference old_pointer_space_allocation_limit_address(
+      Isolate* isolate);
 
   static ExternalReference double_fp_operation(Token::Value operation,
                                                Isolate* isolate);
diff --git a/src/ast.cc b/src/ast.cc
index 02c815c..712bfd1 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1007,11 +1007,6 @@
     add_flag(kDontInline); \
     add_flag(kDontSelfOptimize); \
   }
-#define DONT_INLINE_NODE(NodeType) \
-  void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
-    increase_node_count(); \
-    add_flag(kDontInline); \
-  }
 #define DONT_SELFOPTIMIZE_NODE(NodeType) \
   void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
     increase_node_count(); \
@@ -1038,8 +1033,10 @@
 REGULAR_NODE(SwitchStatement)
 REGULAR_NODE(Conditional)
 REGULAR_NODE(Literal)
+REGULAR_NODE(ArrayLiteral)
 REGULAR_NODE(ObjectLiteral)
 REGULAR_NODE(RegExpLiteral)
+REGULAR_NODE(FunctionLiteral)
 REGULAR_NODE(Assignment)
 REGULAR_NODE(Throw)
 REGULAR_NODE(Property)
@@ -1070,9 +1067,6 @@
 DONT_OPTIMIZE_NODE(DebuggerStatement)
 DONT_OPTIMIZE_NODE(SharedFunctionInfoLiteral)
 
-DONT_INLINE_NODE(ArrayLiteral)  // TODO(1322): Allow materialized literals.
-DONT_INLINE_NODE(FunctionLiteral)
-
 DONT_SELFOPTIMIZE_NODE(DoWhileStatement)
 DONT_SELFOPTIMIZE_NODE(WhileStatement)
 DONT_SELFOPTIMIZE_NODE(ForStatement)
@@ -1099,7 +1093,6 @@
 
 #undef REGULAR_NODE
 #undef DONT_OPTIMIZE_NODE
-#undef DONT_INLINE_NODE
 #undef DONT_SELFOPTIMIZE_NODE
 #undef DONT_CACHE_NODE
 
diff --git a/src/builtins.cc b/src/builtins.cc
index aa69203..f8d562b 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -203,12 +203,6 @@
     holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray);
   }
 
-  ASSERT(function->has_initial_map());
-  ElementsKind kind = function->initial_map()->elements_kind();
-  if (holey) {
-    kind = GetHoleyElementsKind(kind);
-  }
-
   MaybeObject* maybe_array;
   if (*type_info != isolate->heap()->undefined_value()) {
     JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info);
@@ -224,14 +218,20 @@
       AllocationSiteMode mode = AllocationSiteInfo::GetMode(to_kind);
       if (mode == TRACK_ALLOCATION_SITE) {
         maybe_array = isolate->heap()->AllocateEmptyJSArrayWithAllocationSite(
-            kind, type_info);
+            to_kind, type_info);
       } else {
-        maybe_array = isolate->heap()->AllocateEmptyJSArray(kind);
+        maybe_array = isolate->heap()->AllocateEmptyJSArray(to_kind);
       }
       if (!maybe_array->To(&array)) return maybe_array;
     }
   }
 
+  ASSERT(function->has_initial_map());
+  ElementsKind kind = function->initial_map()->elements_kind();
+  if (holey) {
+    kind = GetHoleyElementsKind(kind);
+  }
+
   if (array == NULL) {
     maybe_array = isolate->heap()->AllocateEmptyJSArray(kind);
     if (!maybe_array->To(&array)) return maybe_array;
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index bb8bfe3..ae198bc 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -39,7 +39,7 @@
   Isolate* isolate =  graph->isolate();
   AssertNoAllocation no_gc;
   NoHandleAllocation no_handles(isolate);
-  NoHandleDereference no_deref(isolate);
+  HandleDereferenceGuard no_deref(isolate, HandleDereferenceGuard::DISALLOW);
 
   ASSERT(graph != NULL);
   SmartArrayPointer<char> bailout_reason;
@@ -189,11 +189,16 @@
 
   HValue* size_in_bytes =
       AddInstruction(new(zone) HConstant(size, Representation::Integer32()));
+  HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
+  if (FLAG_pretenure_literals) {
+    flags = static_cast<HAllocate::Flags>(
+       flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
+  }
   HInstruction* object =
       AddInstruction(new(zone) HAllocate(context(),
                                          size_in_bytes,
                                          HType::JSObject(),
-                                         HAllocate::CAN_ALLOCATE_IN_NEW_SPACE));
+                                         flags));
 
   for (int i = 0; i < size; i += kPointerSize) {
     HInstruction* value =
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 151a51c..e91b241 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -149,10 +149,10 @@
 
   virtual ~CodeStub() {}
 
-  bool CompilingCallsToThisStubIsGCSafe() {
+  bool CompilingCallsToThisStubIsGCSafe(Isolate* isolate) {
     bool is_pregenerated = IsPregenerated();
     Code* code = NULL;
-    CHECK(!is_pregenerated || FindCodeInCache(&code, Isolate::Current()));
+    CHECK(!is_pregenerated || FindCodeInCache(&code, isolate));
     return is_pregenerated;
   }
 
diff --git a/src/compiler.cc b/src/compiler.cc
index 8f4be0c..e51fb42 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -396,7 +396,7 @@
 OptimizingCompiler::Status OptimizingCompiler::OptimizeGraph() {
   AssertNoAllocation no_gc;
   NoHandleAllocation no_handles(isolate());
-  NoHandleDereference no_deref(isolate());
+  HandleDereferenceGuard no_deref(isolate(), HandleDereferenceGuard::DISALLOW);
 
   ASSERT(last_status() == SUCCEEDED);
   Timer t(this, &time_taken_to_optimize_);
@@ -943,7 +943,9 @@
             new(info->zone()) OptimizingCompiler(*info);
         OptimizingCompiler::Status status = compiler->CreateGraph();
         if (status == OptimizingCompiler::SUCCEEDED) {
-          closure->MarkInRecompileQueue();
+          // Do a scavenge to put off the next scavenge as far as possible.
+          // This may ease the issue that GVN blocks the next scavenge.
+          isolate->heap()->CollectGarbage(NEW_SPACE, "parallel recompile");
           shared->code()->set_profiler_ticks(0);
           info.Detach();
           isolate->optimizing_compiler_thread()->QueueForOptimization(compiler);
@@ -975,7 +977,19 @@
 
 void Compiler::InstallOptimizedCode(OptimizingCompiler* optimizing_compiler) {
   SmartPointer<CompilationInfo> info(optimizing_compiler->info());
-  ASSERT(info->closure()->IsMarkedForInstallingRecompiledCode());
+  // The function may have already been optimized by OSR.  Simply continue.
+  // Except when OSR already disabled optimization for some reason.
+  if (info->shared_info()->optimization_disabled()) {
+    info->SetCode(Handle<Code>(info->shared_info()->code()));
+    InstallFullCode(*info);
+    if (FLAG_trace_parallel_recompilation) {
+      PrintF("  ** aborting optimization for ");
+      info->closure()->PrintName();
+      PrintF(" as it has been disabled.\n");
+    }
+    ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
+    return;
+  }
 
   Isolate* isolate = info->isolate();
   VMState state(isolate, PARALLEL_COMPILER);
@@ -1015,6 +1029,7 @@
   // Optimized code is finally replacing unoptimized code.  Reset the latter's
   // profiler ticks to prevent too soon re-opt after a deopt.
   info->shared_info()->code()->set_profiler_ticks(0);
+  ASSERT(!info->closure()->IsMarkedForInstallingRecompiledCode());
 }
 
 
diff --git a/src/d8-debug.cc b/src/d8-debug.cc
index f044328..a20de43 100644
--- a/src/d8-debug.cc
+++ b/src/d8-debug.cc
@@ -54,7 +54,9 @@
                       Handle<Object> exec_state,
                       Handle<Object> event_data,
                       Handle<Value> data) {
-  HandleScope scope;
+  // TODO(svenpanne) There should be a way to retrieve this in the callback.
+  Isolate* isolate = Isolate::GetCurrent();
+  HandleScope scope(isolate);
 
   // Check for handled event.
   if (event != Break && event != Exception && event != AfterCompile) {
@@ -69,7 +71,7 @@
       Function::Cast(*event_data->Get(to_json_fun_name));
   Local<Value> event_json = to_json_fun->Call(event_data, 0, NULL);
   if (try_catch.HasCaught()) {
-    Shell::ReportException(&try_catch);
+    Shell::ReportException(isolate, &try_catch);
     return;
   }
 
@@ -77,7 +79,7 @@
   Handle<Object> details =
       Shell::DebugMessageDetails(Handle<String>::Cast(event_json));
   if (try_catch.HasCaught()) {
-    Shell::ReportException(&try_catch);
+    Shell::ReportException(isolate, &try_catch);
     return;
   }
   String::Utf8Value str(details->Get(String::New("text")));
@@ -93,7 +95,7 @@
   Local<Object> cmd_processor =
       Object::Cast(*fun->Call(exec_state, 0, NULL));
   if (try_catch.HasCaught()) {
-    Shell::ReportException(&try_catch);
+    Shell::ReportException(isolate, &try_catch);
     return;
   }
 
@@ -114,7 +116,7 @@
     Handle<Value> request =
         Shell::DebugCommandToJSONRequest(String::New(command));
     if (try_catch.HasCaught()) {
-      Shell::ReportException(&try_catch);
+      Shell::ReportException(isolate, &try_catch);
       continue;
     }
 
@@ -138,7 +140,7 @@
     args[0] = request;
     Handle<Value> response_val = fun->Call(cmd_processor, kArgc, args);
     if (try_catch.HasCaught()) {
-      Shell::ReportException(&try_catch);
+      Shell::ReportException(isolate, &try_catch);
       continue;
     }
     Handle<String> response = Handle<String>::Cast(response_val);
@@ -146,7 +148,7 @@
     // Convert the debugger response into text details and the running state.
     Handle<Object> response_details = Shell::DebugMessageDetails(response);
     if (try_catch.HasCaught()) {
-      Shell::ReportException(&try_catch);
+      Shell::ReportException(isolate, &try_catch);
       continue;
     }
     String::Utf8Value text_str(response_details->Get(String::New("text")));
@@ -159,8 +161,8 @@
 }
 
 
-void RunRemoteDebugger(int port) {
-  RemoteDebugger debugger(port);
+void RunRemoteDebugger(Isolate* isolate, int port) {
+  RemoteDebugger debugger(isolate, port);
   debugger.Run();
 }
 
@@ -273,15 +275,15 @@
 
 
 void RemoteDebugger::HandleMessageReceived(char* message) {
-  Locker lock(v8::Isolate::GetCurrent());
-  HandleScope scope;
+  Locker lock(isolate_);
+  HandleScope scope(isolate_);
 
   // Print the event details.
   TryCatch try_catch;
   Handle<Object> details =
       Shell::DebugMessageDetails(Handle<String>::Cast(String::New(message)));
   if (try_catch.HasCaught()) {
-    Shell::ReportException(&try_catch);
+    Shell::ReportException(isolate_, &try_catch);
     PrintPrompt();
     return;
   }
@@ -302,15 +304,15 @@
 
 
 void RemoteDebugger::HandleKeyboardCommand(char* command) {
-  Locker lock(v8::Isolate::GetCurrent());
-  HandleScope scope;
+  Locker lock(isolate_);
+  HandleScope scope(isolate_);
 
   // Convert the debugger command to a JSON debugger request.
   TryCatch try_catch;
   Handle<Value> request =
       Shell::DebugCommandToJSONRequest(String::New(command));
   if (try_catch.HasCaught()) {
-    Shell::ReportException(&try_catch);
+    Shell::ReportException(isolate_, &try_catch);
     PrintPrompt();
     return;
   }
diff --git a/src/d8-debug.h b/src/d8-debug.h
index aeff3c1..a6cea2a 100644
--- a/src/d8-debug.h
+++ b/src/d8-debug.h
@@ -43,7 +43,7 @@
 
 // Start the remove debugger connecting to a V8 debugger agent on the specified
 // port.
-void RunRemoteDebugger(int port);
+void RunRemoteDebugger(Isolate* isolate, int port);
 
 // Forward declerations.
 class RemoteDebuggerEvent;
@@ -53,8 +53,9 @@
 // Remote debugging class.
 class RemoteDebugger {
  public:
-  explicit RemoteDebugger(int port)
-      : port_(port),
+  explicit RemoteDebugger(Isolate* isolate, int port)
+      : isolate_(isolate),
+        port_(port),
         event_access_(i::OS::CreateMutex()),
         event_available_(i::OS::CreateSemaphore(0)),
         head_(NULL), tail_(NULL) {}
@@ -79,6 +80,7 @@
   // Get connection to agent in debugged V8.
   i::Socket* conn() { return conn_; }
 
+  Isolate* isolate_;
   int port_;  // Port used to connect to debugger V8.
   i::Socket* conn_;  // Connection to debugger agent in debugged V8.
 
diff --git a/src/d8-posix.cc b/src/d8-posix.cc
index 8a278e4..1be782a 100644
--- a/src/d8-posix.cc
+++ b/src/d8-posix.cc
@@ -449,7 +449,7 @@
 
 // Implementation of the system() function (see d8.h for details).
 Handle<Value> Shell::System(const Arguments& args) {
-  HandleScope scope;
+  HandleScope scope(args.GetIsolate());
   int read_timeout = -1;
   int total_timeout = -1;
   if (!GetTimeouts(args, &read_timeout, &total_timeout)) return v8::Undefined();
diff --git a/src/d8-readline.cc b/src/d8-readline.cc
index cc7a3a6..5226364 100644
--- a/src/d8-readline.cc
+++ b/src/d8-readline.cc
@@ -154,7 +154,7 @@
     HandleScope scope;
     Local<String> full_text = String::New(rl_line_buffer, rl_point);
     Handle<Array> completions =
-      Shell::GetCompletions(String::New(text), full_text);
+        Shell::GetCompletions(isolate, String::New(text), full_text);
     current_completions = Persistent<Array>::New(isolate, completions);
     current_index = 0;
   }
diff --git a/src/d8.cc b/src/d8.cc
index 24c89e9..eaebd90 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -93,7 +93,7 @@
 class Symbols {
  public:
   explicit Symbols(Isolate* isolate) : isolate_(isolate) {
-    HandleScope scope;
+    HandleScope scope(isolate);
 #define INIT_SYMBOL(name, value) \
     name##_ = Persistent<String>::New(isolate, String::NewSymbol(value));
     FOR_EACH_SYMBOL(INIT_SYMBOL)
@@ -181,7 +181,8 @@
 
 
 // Executes a string within the current v8 context.
-bool Shell::ExecuteString(Handle<String> source,
+bool Shell::ExecuteString(Isolate* isolate,
+                          Handle<String> source,
                           Handle<Value> name,
                           bool print_result,
                           bool report_exceptions) {
@@ -190,7 +191,7 @@
 #else
   bool FLAG_debugger = false;
 #endif  // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
-  HandleScope handle_scope;
+  HandleScope handle_scope(isolate);
   TryCatch try_catch;
   options.script_executed = true;
   if (FLAG_debugger) {
@@ -201,7 +202,7 @@
   if (script.IsEmpty()) {
     // Print errors that happened during compilation.
     if (report_exceptions && !FLAG_debugger)
-      ReportException(&try_catch);
+      ReportException(isolate, &try_catch);
     return false;
   } else {
     Handle<Value> result = script->Run();
@@ -209,7 +210,7 @@
       ASSERT(try_catch.HasCaught());
       // Print errors that happened during execution.
       if (report_exceptions && !FLAG_debugger)
-        ReportException(&try_catch);
+        ReportException(isolate, &try_catch);
       return false;
     } else {
       ASSERT(!try_catch.HasCaught());
@@ -237,7 +238,7 @@
 
 Handle<Value> Shell::Write(const Arguments& args) {
   for (int i = 0; i < args.Length(); i++) {
-    HandleScope handle_scope;
+    HandleScope handle_scope(args.GetIsolate());
     if (i != 0) {
       printf(" ");
     }
@@ -315,7 +316,7 @@
 
 Handle<Value> Shell::Load(const Arguments& args) {
   for (int i = 0; i < args.Length(); i++) {
-    HandleScope handle_scope;
+    HandleScope handle_scope(args.GetIsolate());
     String::Utf8Value file(args[i]);
     if (*file == NULL) {
       return Throw("Error loading file");
@@ -324,7 +325,11 @@
     if (source.IsEmpty()) {
       return Throw("Error loading file");
     }
-    if (!ExecuteString(source, String::New(*file), false, true)) {
+    if (!ExecuteString(args.GetIsolate(),
+                       source,
+                       String::New(*file),
+                       false,
+                       true)) {
       return Throw("Error executing file");
     }
   }
@@ -389,7 +394,7 @@
       Persistent<Object>::New(isolate, buffer);
   persistent_array.MakeWeak(isolate, data, ExternalArrayWeakCallback);
   persistent_array.MarkIndependent(isolate);
-  V8::AdjustAmountOfExternalAllocatedMemory(length);
+  isolate->AdjustAmountOfExternalAllocatedMemory(length);
 
   buffer->SetIndexedPropertiesToExternalArrayData(
       data, v8::kExternalByteArray, length);
@@ -827,10 +832,10 @@
 void Shell::ExternalArrayWeakCallback(v8::Isolate* isolate,
                                       Persistent<Value> object,
                                       void* data) {
-  HandleScope scope;
+  HandleScope scope(isolate);
   int32_t length =
       object->ToObject()->Get(Symbols::byteLength(isolate))->Uint32Value();
-  V8::AdjustAmountOfExternalAllocatedMemory(-length);
+  isolate->AdjustAmountOfExternalAllocatedMemory(-length);
   delete[] static_cast<uint8_t*>(data);
   object.Dispose(isolate);
 }
@@ -903,8 +908,8 @@
 }
 
 
-void Shell::ReportException(v8::TryCatch* try_catch) {
-  HandleScope handle_scope;
+void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
+  HandleScope handle_scope(isolate);
 #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
   bool enter_context = !Context::InContext();
   if (enter_context) utility_context_->Enter();
@@ -950,8 +955,10 @@
 
 
 #ifndef V8_SHARED
-Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) {
-  HandleScope handle_scope;
+Handle<Array> Shell::GetCompletions(Isolate* isolate,
+                                    Handle<String> text,
+                                    Handle<String> full) {
+  HandleScope handle_scope(isolate);
   Context::Scope context_scope(utility_context_);
   Handle<Object> global = utility_context_->Global();
   Handle<Value> fun = global->Get(String::New("GetCompletions"));
@@ -1094,7 +1101,7 @@
 
 void Shell::InstallUtilityScript(Isolate* isolate) {
   Locker lock(isolate);
-  HandleScope scope;
+  HandleScope scope(isolate);
   // If we use the utility context, we have to set the security tokens so that
   // utility, evaluation and debug context can all access each other.
   utility_context_->SetSecurityToken(Undefined(isolate));
@@ -1272,7 +1279,7 @@
   if (options.test_shell) return;
 #ifndef V8_SHARED
   Locker lock(isolate);
-  HandleScope scope;
+  HandleScope scope(isolate);
   Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
   utility_context_ = Context::New(NULL, global_template);
 
@@ -1446,7 +1453,7 @@
       Persistent<Object>::New(isolate, buffer);
   persistent_buffer.MakeWeak(isolate, data, ExternalArrayWeakCallback);
   persistent_buffer.MarkIndependent(isolate);
-  V8::AdjustAmountOfExternalAllocatedMemory(length);
+  isolate->AdjustAmountOfExternalAllocatedMemory(length);
 
   buffer->SetIndexedPropertiesToExternalArrayData(
       data, kExternalUnsignedByteArray, length);
@@ -1493,16 +1500,16 @@
 void Shell::RunShell(Isolate* isolate) {
   Locker locker(isolate);
   Context::Scope context_scope(evaluation_context_);
-  HandleScope outer_scope;
+  HandleScope outer_scope(isolate);
   Handle<String> name = String::New("(d8)");
   LineEditor* console = LineEditor::Get();
   printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name());
   console->Open(isolate);
   while (true) {
-    HandleScope inner_scope;
+    HandleScope inner_scope(isolate);
     Handle<String> input = console->Prompt(Shell::kPrompt);
     if (input.IsEmpty()) break;
-    ExecuteString(input, name, true, true);
+    ExecuteString(isolate, input, name, true, true);
   }
   printf("\n");
 }
@@ -1541,13 +1548,13 @@
 
     // Prepare the context for this thread.
     Locker locker(isolate_);
-    HandleScope outer_scope;
+    HandleScope outer_scope(isolate_);
     Persistent<Context> thread_context =
         Shell::CreateEvaluationContext(isolate_);
     Context::Scope context_scope(thread_context);
 
     while ((ptr != NULL) && (*ptr != '\0')) {
-      HandleScope inner_scope;
+      HandleScope inner_scope(isolate_);
       char* filename = ptr;
       ptr = ReadWord(ptr);
 
@@ -1562,7 +1569,7 @@
         Shell::Exit(1);
       }
 
-      Shell::ExecuteString(str, String::New(filename), false, false);
+      Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
     }
 
     thread_context.Dispose(thread_context->GetIsolate());
@@ -1589,10 +1596,10 @@
     const char* arg = argv_[i];
     if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) {
       // Execute argument given to -e option directly.
-      HandleScope handle_scope;
+      HandleScope handle_scope(isolate);
       Handle<String> file_name = String::New("unnamed");
       Handle<String> source = String::New(argv_[i + 1]);
-      if (!Shell::ExecuteString(source, file_name, false, true)) {
+      if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
         Shell::Exit(1);
       }
       ++i;
@@ -1600,14 +1607,14 @@
       // Ignore other options. They have been parsed already.
     } else {
       // Use all other arguments as names of files to load and run.
-      HandleScope handle_scope;
+      HandleScope handle_scope(isolate);
       Handle<String> file_name = String::New(arg);
       Handle<String> source = ReadFile(isolate, arg);
       if (source.IsEmpty()) {
         printf("Error reading '%s'\n", arg);
         Shell::Exit(1);
       }
-      if (!Shell::ExecuteString(source, file_name, false, true)) {
+      if (!Shell::ExecuteString(isolate, source, file_name, false, true)) {
         Shell::Exit(1);
       }
     }
@@ -1642,7 +1649,7 @@
     {
       Isolate::Scope iscope(isolate);
       Locker lock(isolate);
-      HandleScope scope;
+      HandleScope scope(isolate);
       Symbols symbols(isolate);
       Persistent<Context> context = Shell::CreateEvaluationContext(isolate);
       {
@@ -1840,7 +1847,7 @@
 #endif  // V8_SHARED
   {  // NOLINT
     Locker lock(isolate);
-    HandleScope scope;
+    HandleScope scope(isolate);
     Persistent<Context> context = CreateEvaluationContext(isolate);
     if (options.last_run) {
       // Keep using the same context in the interactive shell.
@@ -1936,7 +1943,7 @@
     // Run remote debugger if requested, but never on --test
     if (i::FLAG_remote_debugger && !options.test_shell) {
       InstallUtilityScript(isolate);
-      RunRemoteDebugger(i::FLAG_debugger_port);
+      RunRemoteDebugger(isolate, i::FLAG_debugger_port);
       return 0;
     }
 #endif  // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
diff --git a/src/d8.h b/src/d8.h
index 04c5454..621ac74 100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -265,12 +265,13 @@
 #endif  // V8_SHARED
 
  public:
-  static bool ExecuteString(Handle<String> source,
+  static bool ExecuteString(Isolate* isolate,
+                            Handle<String> source,
                             Handle<Value> name,
                             bool print_result,
                             bool report_exceptions);
   static const char* ToCString(const v8::String::Utf8Value& value);
-  static void ReportException(TryCatch* try_catch);
+  static void ReportException(Isolate* isolate, TryCatch* try_catch);
   static Handle<String> ReadFile(Isolate* isolate, const char* name);
   static Persistent<Context> CreateEvaluationContext(Isolate* isolate);
   static int RunMain(Isolate* isolate, int argc, char* argv[]);
@@ -279,7 +280,8 @@
   static void OnExit();
 
 #ifndef V8_SHARED
-  static Handle<Array> GetCompletions(Handle<String> text,
+  static Handle<Array> GetCompletions(Isolate* isolate,
+                                      Handle<String> text,
                                       Handle<String> full);
   static int* LookupCounter(const char* name);
   static void* CreateHistogram(const char* name,
diff --git a/src/debug.cc b/src/debug.cc
index 2821578..1fd3e40 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -3567,7 +3567,8 @@
 
 
 v8::Handle<v8::String> MessageImpl::GetJSON() const {
-  v8::HandleScope scope;
+  v8::HandleScope scope(
+      reinterpret_cast<v8::Isolate*>(event_data_->GetIsolate()));
 
   if (IsEvent()) {
     // Call toJSONProtocol on the debug event object.
diff --git a/src/disassembler.cc b/src/disassembler.cc
index 5d18d68..3830759 100644
--- a/src/disassembler.cc
+++ b/src/disassembler.cc
@@ -282,7 +282,7 @@
         if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
           out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data()));
         }
-      } else if (rmode == RelocInfo::RUNTIME_ENTRY &&
+      } else if (RelocInfo::IsRuntimeEntry(rmode) &&
                  isolate->deoptimizer_data() != NULL) {
         // A runtime entry reloinfo might be a deoptimization bailout.
         Address addr = relocinfo.target_address();
diff --git a/src/execution.h b/src/execution.h
index c350805..b104180 100644
--- a/src/execution.h
+++ b/src/execution.h
@@ -189,8 +189,6 @@
   void Interrupt();
   bool IsTerminateExecution();
   void TerminateExecution();
-  bool IsCodeReadyEvent();
-  void RequestCodeReadyEvent();
 #ifdef ENABLE_DEBUGGER_SUPPORT
   bool IsDebugBreak();
   void DebugBreak();
diff --git a/src/factory.cc b/src/factory.cc
index 9135d54..fece9a0 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -703,9 +703,11 @@
 }
 
 
-Handle<Object> Factory::NewError(const char* maker, const char* type,
-    Vector< Handle<Object> > args) {
-  v8::HandleScope scope;  // Instantiate a closeable HandleScope for EscapeFrom.
+Handle<Object> Factory::NewError(const char* maker,
+                                 const char* type,
+                                 Vector< Handle<Object> > args) {
+  // Instantiate a closeable HandleScope for EscapeFrom.
+  v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate()));
   Handle<FixedArray> array = NewFixedArray(args.length());
   for (int i = 0; i < args.length(); i++) {
     array->set(i, *args[i]);
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index 3a2426b..c4b560b 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -166,6 +166,7 @@
 DEFINE_bool(clever_optimizations,
             true,
             "Optimize object size, Array shift, DOM strings and string +")
+DEFINE_bool(pretenure_literals, false, "allocate literals in old space")
 
 // Flags for data representation optimizations
 DEFINE_bool(unbox_double_arrays, true, "automatically unbox arrays of doubles")
diff --git a/src/flags.cc b/src/flags.cc
index bca0eff..ff725ad 100644
--- a/src/flags.cc
+++ b/src/flags.cc
@@ -542,6 +542,7 @@
 void FlagList::EnforceFlagImplications() {
 #define FLAG_MODE_DEFINE_IMPLICATIONS
 #include "flag-definitions.h"
+#undef FLAG_MODE_DEFINE_IMPLICATIONS
 }
 
 } }  // namespace v8::internal
diff --git a/src/handles-inl.h b/src/handles-inl.h
index c1daae2..fd60a35 100644
--- a/src/handles-inl.h
+++ b/src/handles-inl.h
@@ -52,10 +52,26 @@
 
 
 template <typename T>
+inline bool Handle<T>::is_identical_to(const Handle<T> other) const {
+  ASSERT(location_ == NULL ||
+         reinterpret_cast<Address>(*location_) != kZapValue);
+#ifdef DEBUG
+  if (FLAG_enable_slow_asserts) {
+    Isolate* isolate = Isolate::Current();
+    CHECK(isolate->AllowHandleDereference() ||
+          Heap::RelocationLock::IsLocked(isolate->heap()) ||
+          !isolate->optimizing_compiler_thread()->IsOptimizerThread());
+  }
+#endif  // DEBUG
+  return *location_ == *other.location_;
+}
+
+
+template <typename T>
 inline T* Handle<T>::operator*() const {
   ASSERT(location_ != NULL);
   ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue);
-  SLOW_ASSERT(ISOLATE->allow_handle_deref());
+  SLOW_ASSERT(Isolate::Current()->AllowHandleDereference());
   return *BitCast<T**>(location_);
 }
 
@@ -63,7 +79,7 @@
 inline T** Handle<T>::location() const {
   ASSERT(location_ == NULL ||
          reinterpret_cast<Address>(*location_) != kZapValue);
-  SLOW_ASSERT(ISOLATE->allow_handle_deref());
+  SLOW_ASSERT(Isolate::Current()->AllowHandleDereference());
   return location_;
 }
 
@@ -164,39 +180,19 @@
 }
 
 
-NoHandleDereference::NoHandleDereference(Isolate* isolate)
+HandleDereferenceGuard::HandleDereferenceGuard(Isolate* isolate, State state)
     : isolate_(isolate) {
-  // The guard is set on a per-isolate basis, so it affects all threads.
-  // That's why we can only use it when running without parallel recompilation.
-  if (FLAG_parallel_recompilation) return;
-  old_state_ = isolate->allow_handle_deref();
-  isolate_->set_allow_handle_deref(false);
+  old_state_ = isolate_->AllowHandleDereference();
+  isolate_->SetAllowHandleDereference(state == ALLOW);
 }
 
 
-NoHandleDereference::~NoHandleDereference() {
-  if (FLAG_parallel_recompilation) return;
-  isolate_->set_allow_handle_deref(old_state_);
+HandleDereferenceGuard::~HandleDereferenceGuard() {
+  isolate_->SetAllowHandleDereference(old_state_);
 }
 
-
-AllowHandleDereference::AllowHandleDereference(Isolate* isolate)
-    : isolate_(isolate) {
-  // The guard is set on a per-isolate basis, so it affects all threads.
-  // That's why we can only use it when running without parallel recompilation.
-  if (FLAG_parallel_recompilation) return;
-  old_state_ = isolate->allow_handle_deref();
-  isolate_->set_allow_handle_deref(true);
-}
-
-
-AllowHandleDereference::~AllowHandleDereference() {
-  if (FLAG_parallel_recompilation) return;
-  isolate_->set_allow_handle_deref(old_state_);
-}
 #endif
 
-
 } }  // namespace v8::internal
 
 #endif  // V8_HANDLES_INL_H_
diff --git a/src/handles.h b/src/handles.h
index b0b271c..3e408b7 100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -64,9 +64,7 @@
   INLINE(T* operator ->() const) { return operator*(); }
 
   // Check if this handle refers to the exact same object as the other handle.
-  bool is_identical_to(const Handle<T> other) const {
-    return *location_ == *other.location_;
-  }
+  INLINE(bool is_identical_to(const Handle<T> other) const);
 
   // Provides the C++ dereference operator.
   INLINE(T* operator*() const);
@@ -341,29 +339,15 @@
 };
 
 
-class NoHandleDereference BASE_EMBEDDED {
+class HandleDereferenceGuard BASE_EMBEDDED {
  public:
+  enum State { ALLOW, DISALLOW };
 #ifndef DEBUG
-  explicit NoHandleDereference(Isolate* isolate) {}
-  ~NoHandleDereference() {}
+  HandleDereferenceGuard(Isolate* isolate, State state) { }
+  ~HandleDereferenceGuard() { }
 #else
-  explicit inline NoHandleDereference(Isolate* isolate);
-  inline ~NoHandleDereference();
- private:
-  Isolate* isolate_;
-  bool old_state_;
-#endif
-};
-
-
-class AllowHandleDereference BASE_EMBEDDED {
- public:
-#ifndef DEBUG
-  explicit AllowHandleDereference(Isolate* isolate) {}
-  ~AllowHandleDereference() {}
-#else
-  explicit inline AllowHandleDereference(Isolate* isolate);
-  inline ~AllowHandleDereference();
+  inline HandleDereferenceGuard(Isolate* isolate,  State state);
+  inline ~HandleDereferenceGuard();
  private:
   Isolate* isolate_;
   bool old_state_;
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 3644876..9ed65d8 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -653,24 +653,12 @@
     // TODO(yangguo): check that the object is indeed an external string.
     ASSERT(heap_->InNewSpace(obj));
     ASSERT(obj != HEAP->the_hole_value());
-#ifndef ENABLE_LATIN_1
-    if (obj->IsExternalAsciiString()) {
-      ExternalAsciiString* string = ExternalAsciiString::cast(obj);
-      ASSERT(String::IsAscii(string->GetChars(), string->length()));
-    }
-#endif
   }
   for (int i = 0; i < old_space_strings_.length(); ++i) {
     Object* obj = Object::cast(old_space_strings_[i]);
     // TODO(yangguo): check that the object is indeed an external string.
     ASSERT(!heap_->InNewSpace(obj));
     ASSERT(obj != HEAP->the_hole_value());
-#ifndef ENABLE_LATIN_1
-    if (obj->IsExternalAsciiString()) {
-      ExternalAsciiString* string = ExternalAsciiString::cast(obj);
-      ASSERT(String::IsAscii(string->GetChars(), string->length()));
-    }
-#endif
   }
 #endif
 }
diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc
index 5f46678..cdd5a07 100644
--- a/src/heap-snapshot-generator.cc
+++ b/src/heap-snapshot-generator.cc
@@ -174,6 +174,7 @@
     case kHeapNumber: return "/number/";
     case kNative: return "/native/";
     case kSynthetic: return "/synthetic/";
+    case kContext: return "/context/";
     default: return "???";
   }
 }
@@ -826,7 +827,7 @@
   } else if (object->IsNativeContext()) {
     return AddEntry(object, HeapEntry::kHidden, "system / NativeContext");
   } else if (object->IsContext()) {
-    return AddEntry(object, HeapEntry::kHidden, "system / Context");
+    return AddEntry(object, HeapEntry::kContext, "system / Context");
   } else if (object->IsFixedArray() ||
              object->IsFixedDoubleArray() ||
              object->IsByteArray() ||
@@ -1097,6 +1098,27 @@
 
 
 void V8HeapExplorer::ExtractContextReferences(int entry, Context* context) {
+  if (context == context->declaration_context()) {
+    ScopeInfo* scope_info = context->closure()->shared()->scope_info();
+    // Add context allocated locals.
+    int context_locals = scope_info->ContextLocalCount();
+    for (int i = 0; i < context_locals; ++i) {
+      String* local_name = scope_info->ContextLocalName(i);
+      int idx = Context::MIN_CONTEXT_SLOTS + i;
+      SetContextReference(context, entry, local_name, context->get(idx),
+                          Context::OffsetOfElementAt(idx));
+    }
+    if (scope_info->HasFunctionName()) {
+      String* name = scope_info->FunctionName();
+      VariableMode mode;
+      int idx = scope_info->FunctionContextSlotIndex(name, &mode);
+      if (idx >= 0) {
+        SetContextReference(context, entry, name, context->get(idx),
+                            Context::OffsetOfElementAt(idx));
+      }
+    }
+  }
+
 #define EXTRACT_CONTEXT_FIELD(index, type, name) \
   SetInternalReference(context, entry, #name, context->get(Context::index), \
       FixedArray::OffsetOfElementAt(Context::index));
@@ -1286,26 +1308,6 @@
       SetNativeBindReference(js_obj, entry, reference_name,
                              bindings->get(i));
     }
-  } else {
-    Context* context = func->context()->declaration_context();
-    ScopeInfo* scope_info = context->closure()->shared()->scope_info();
-    // Add context allocated locals.
-    int context_locals = scope_info->ContextLocalCount();
-    for (int i = 0; i < context_locals; ++i) {
-      String* local_name = scope_info->ContextLocalName(i);
-      int idx = Context::MIN_CONTEXT_SLOTS + i;
-      SetClosureReference(js_obj, entry, local_name, context->get(idx));
-    }
-
-    // Add function variable.
-    if (scope_info->HasFunctionName()) {
-      String* name = scope_info->FunctionName();
-      VariableMode mode;
-      int idx = scope_info->FunctionContextSlotIndex(name, &mode);
-      if (idx >= 0) {
-        SetClosureReference(js_obj, entry, name, context->get(idx));
-      }
-    }
   }
 }
 
@@ -1580,16 +1582,18 @@
 }
 
 
-void V8HeapExplorer::SetClosureReference(HeapObject* parent_obj,
+void V8HeapExplorer::SetContextReference(HeapObject* parent_obj,
                                          int parent_entry,
                                          String* reference_name,
-                                         Object* child_obj) {
+                                         Object* child_obj,
+                                         int field_offset) {
   HeapEntry* child_entry = GetEntry(child_obj);
   if (child_entry != NULL) {
     filler_->SetNamedReference(HeapGraphEdge::kContextVariable,
                                parent_entry,
                                collection_->names()->GetName(reference_name),
                                child_entry);
+    IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
   }
 }
 
@@ -2576,7 +2580,8 @@
             JSON_S("regexp") ","
             JSON_S("number") ","
             JSON_S("native") ","
-            JSON_S("synthetic")) ","
+            JSON_S("synthetic") ","
+            JSON_S("context")) ","
         JSON_S("string") ","
         JSON_S("number") ","
         JSON_S("number") ","
diff --git a/src/heap-snapshot-generator.h b/src/heap-snapshot-generator.h
index fe15715..c952381 100644
--- a/src/heap-snapshot-generator.h
+++ b/src/heap-snapshot-generator.h
@@ -98,7 +98,8 @@
     kRegExp = v8::HeapGraphNode::kRegExp,
     kHeapNumber = v8::HeapGraphNode::kHeapNumber,
     kNative = v8::HeapGraphNode::kNative,
-    kSynthetic = v8::HeapGraphNode::kSynthetic
+    kSynthetic = v8::HeapGraphNode::kSynthetic,
+    kContext = v8::HeapGraphNode::kContext
   };
   static const int kNoEntry;
 
@@ -479,10 +480,11 @@
   void ExtractElementReferences(JSObject* js_obj, int entry);
   void ExtractInternalReferences(JSObject* js_obj, int entry);
   bool IsEssentialObject(Object* object);
-  void SetClosureReference(HeapObject* parent_obj,
+  void SetContextReference(HeapObject* parent_obj,
                            int parent,
                            String* reference_name,
-                           Object* child);
+                           Object* child,
+                           int field_offset);
   void SetNativeBindReference(HeapObject* parent_obj,
                               int parent,
                               const char* reference_name,
diff --git a/src/heap.cc b/src/heap.cc
index fe1783d..9ee64e3 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3596,10 +3596,6 @@
     return Failure::OutOfMemoryException(0x5);
   }
 
-#ifndef ENABLE_LATIN_1
-  ASSERT(String::IsAscii(resource->data(), static_cast<int>(length)));
-#endif  // ENABLE_LATIN_1
-
   Map* map = external_ascii_string_map();
   Object* result;
   { MaybeObject* maybe_result = Allocate(map, NEW_SPACE);
@@ -5078,17 +5074,6 @@
   String::cast(result)->set_hash_field(String::kEmptyHashField);
   ASSERT_EQ(size, HeapObject::cast(result)->Size());
 
-#ifndef ENABLE_LATIN_1
-#ifdef VERIFY_HEAP
-  if (FLAG_verify_heap) {
-    // Initialize string's content to ensure ASCII-ness (character range 0-127)
-    // as required when verifying the heap.
-    uint8_t* dest = SeqOneByteString::cast(result)->GetChars();
-    memset(dest, 0x0F, length * kCharSize);
-  }
-#endif
-#endif
-
   return result;
 }
 
@@ -6597,6 +6582,9 @@
   store_buffer()->SetUp();
 
   if (FLAG_parallel_recompilation) relocation_mutex_ = OS::CreateMutex();
+#ifdef DEBUG
+  relocation_mutex_locked_ = false;
+#endif  // DEBUG
 
   return true;
 }
diff --git a/src/heap.h b/src/heap.h
index 456e9d8..d26c384 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -590,6 +590,13 @@
     return new_space_.allocation_limit_address();
   }
 
+  Address* OldPointerSpaceAllocationTopAddress() {
+    return old_pointer_space_->allocation_top_address();
+  }
+  Address* OldPointerSpaceAllocationLimitAddress() {
+    return old_pointer_space_->allocation_limit_address();
+  }
+
   // Uncommit unused semi space.
   bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); }
 
@@ -1822,14 +1829,27 @@
     explicit RelocationLock(Heap* heap) : heap_(heap) {
       if (FLAG_parallel_recompilation) {
         heap_->relocation_mutex_->Lock();
+#ifdef DEBUG
+        heap_->relocation_mutex_locked_ = true;
+#endif  // DEBUG
       }
     }
+
     ~RelocationLock() {
       if (FLAG_parallel_recompilation) {
+#ifdef DEBUG
+        heap_->relocation_mutex_locked_ = false;
+#endif  // DEBUG
         heap_->relocation_mutex_->Unlock();
       }
     }
 
+#ifdef DEBUG
+    static bool IsLocked(Heap* heap) {
+      return heap->relocation_mutex_locked_;
+    }
+#endif  // DEBUG
+
    private:
     Heap* heap_;
   };
@@ -2304,6 +2324,9 @@
   MemoryChunk* chunks_queued_for_free_;
 
   Mutex* relocation_mutex_;
+#ifdef DEBUG
+  bool relocation_mutex_locked_;
+#endif  // DEBUG;
 
   friend class Factory;
   friend class GCTracer;
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 8399f0b..20e41bc 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -348,11 +348,7 @@
 }
 
 
-HType HType::TypeFromValue(Isolate* isolate, Handle<Object> value) {
-  // Handle dereferencing is safe here: an object's type as checked below
-  // never changes.
-  AllowHandleDereference allow_handle_deref(isolate);
-
+HType HType::TypeFromValue(Handle<Object> value) {
   HType result = HType::Tagged();
   if (value->IsSmi()) {
     result = HType::Smi();
@@ -1309,10 +1305,7 @@
   }
 
   if (check_ == IS_INTERNALIZED_STRING && value()->IsConstant()) {
-    // Dereferencing is safe here:
-    // an internalized string cannot become non-internalized.
-    AllowHandleDereference allow_handle_deref(isolate());
-    if (HConstant::cast(value())->handle()->IsInternalizedString()) return NULL;
+    if (HConstant::cast(value())->HasInternalizedStringValue()) return NULL;
   }
   return this;
 }
@@ -1814,17 +1807,20 @@
 
 
 HConstant::HConstant(Handle<Object> handle, Representation r)
-    : handle_(handle),
-      has_int32_value_(false),
-      has_double_value_(false) {
-  // Dereferencing here is safe: the value of a number object does not change.
-  AllowHandleDereference allow_handle_deref(Isolate::Current());
+  : handle_(handle),
+    has_int32_value_(false),
+    has_double_value_(false),
+    is_internalized_string_(false),
+    boolean_value_(handle->BooleanValue()) {
   if (handle_->IsNumber()) {
     double n = handle_->Number();
     has_int32_value_ = IsInteger32(n);
     int32_value_ = DoubleToInt32(n);
     double_value_ = n;
     has_double_value_ = true;
+  } else {
+    type_from_value_ = HType::TypeFromValue(handle_);
+    is_internalized_string_ = handle_->IsInternalizedString();
   }
   if (r.IsNone()) {
     if (has_int32_value_) {
@@ -1839,18 +1835,44 @@
 }
 
 
-HConstant::HConstant(int32_t integer_value, Representation r)
+HConstant::HConstant(Handle<Object> handle,
+                     Representation r,
+                     HType type,
+                     bool is_internalize_string,
+                     bool boolean_value)
+    : handle_(handle),
+      has_int32_value_(false),
+      has_double_value_(false),
+      is_internalized_string_(is_internalize_string),
+      boolean_value_(boolean_value),
+      type_from_value_(type) {
+  ASSERT(!handle.is_null());
+  ASSERT(!type.IsUninitialized());
+  ASSERT(!type.IsTaggedNumber());
+  Initialize(r);
+}
+
+
+HConstant::HConstant(int32_t integer_value,
+                     Representation r,
+                     Handle<Object> optional_handle)
     : has_int32_value_(true),
       has_double_value_(true),
+      is_internalized_string_(false),
+      boolean_value_(integer_value != 0),
       int32_value_(integer_value),
       double_value_(FastI2D(integer_value)) {
   Initialize(r);
 }
 
 
-HConstant::HConstant(double double_value, Representation r)
+HConstant::HConstant(double double_value,
+                     Representation r,
+                     Handle<Object> optional_handle)
     : has_int32_value_(IsInteger32(double_value)),
       has_double_value_(true),
+      is_internalized_string_(false),
+      boolean_value_(double_value != 0 && !isnan(double_value)),
       int32_value_(DoubleToInt32(double_value)),
       double_value_(double_value) {
   Initialize(r);
@@ -1869,53 +1891,27 @@
 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
   if (r.IsInteger32() && !has_int32_value_) return NULL;
   if (r.IsDouble() && !has_double_value_) return NULL;
-  if (handle_.is_null()) {
-    ASSERT(has_int32_value_ || has_double_value_);
-    if (has_int32_value_) return new(zone) HConstant(int32_value_, r);
-    return new(zone) HConstant(double_value_, r);
-  }
-  return new(zone) HConstant(handle_, r);
+  if (has_int32_value_) return new(zone) HConstant(int32_value_, r, handle_);
+  if (has_double_value_) return new(zone) HConstant(double_value_, r, handle_);
+  ASSERT(!handle_.is_null());
+  return new(zone) HConstant(
+      handle_, r, type_from_value_, is_internalized_string_, boolean_value_);
 }
 
 
 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const {
   if (has_int32_value_) {
-    if (handle_.is_null()) {
-      return new(zone) HConstant(int32_value_, Representation::Integer32());
-    } else {
-      // Re-use the existing Handle if possible.
-      return new(zone) HConstant(handle_, Representation::Integer32());
-    }
-  } else if (has_double_value_) {
-    return new(zone) HConstant(DoubleToInt32(double_value_),
-                               Representation::Integer32());
-  } else {
-    return NULL;
+    return new(zone) HConstant(
+        int32_value_, Representation::Integer32(), handle_);
   }
+  if (has_double_value_) {
+    return new(zone) HConstant(
+        DoubleToInt32(double_value_), Representation::Integer32(), handle_);
+  }
+  return NULL;
 }
 
 
-bool HConstant::ToBoolean() {
-  // Converts the constant's boolean value according to
-  // ECMAScript section 9.2 ToBoolean conversion.
-  if (HasInteger32Value()) return Integer32Value() != 0;
-  if (HasDoubleValue()) {
-    double v = DoubleValue();
-    return v != 0 && !isnan(v);
-  }
-  // Dereferencing is safe: singletons do not change and strings are
-  // immutable.
-  AllowHandleDereference allow_handle_deref(isolate());
-  if (handle_->IsTrue()) return true;
-  if (handle_->IsFalse()) return false;
-  if (handle_->IsUndefined()) return false;
-  if (handle_->IsNull()) return false;
-  if (handle_->IsString() && String::cast(*handle_)->length() == 0) {
-    return false;
-  }
-  return true;
-}
-
 void HConstant::PrintDataTo(StringStream* stream) {
   if (has_int32_value_) {
     stream->Add("%d ", int32_value_);
@@ -2514,6 +2510,12 @@
 }
 
 
+void HInnerAllocatedObject::PrintDataTo(StringStream* stream) {
+  base_object()->PrintNameTo(stream);
+  stream->Add(" offset %d", offset());
+}
+
+
 void HStoreGlobalCell::PrintDataTo(StringStream* stream) {
   stream->Add("[%p] = ", *cell());
   value()->PrintNameTo(stream);
@@ -2594,7 +2596,8 @@
     return Smi::IsValid(int32_value_) ? HType::Smi() : HType::HeapNumber();
   }
   if (has_double_value_) return HType::HeapNumber();
-  return HType::TypeFromValue(isolate(), handle_);
+  ASSERT(!type_from_value_.IsUninitialized());
+  return type_from_value_;
 }
 
 
@@ -2666,6 +2669,7 @@
 
 void HAllocate::PrintDataTo(StringStream* stream) {
   size()->PrintNameTo(stream);
+  if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)");
 }
 
 
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index b60a23b..29e8c29 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -122,6 +122,7 @@
   V(HasInstanceTypeAndBranch)                  \
   V(InductionVariableAnnotation)               \
   V(In)                                        \
+  V(InnerAllocatedObject)                      \
   V(InstanceOf)                                \
   V(InstanceOfKnownGlobal)                     \
   V(InstanceSize)                              \
@@ -385,7 +386,7 @@
     return HType(static_cast<Type>(type_ & other.type_));
   }
 
-  bool Equals(const HType& other) {
+  bool Equals(const HType& other) const {
     return type_ == other.type_;
   }
 
@@ -393,66 +394,66 @@
     return Combine(other).Equals(other);
   }
 
-  bool IsTagged() {
+  bool IsTagged() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kTagged) == kTagged);
   }
 
-  bool IsTaggedPrimitive() {
+  bool IsTaggedPrimitive() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kTaggedPrimitive) == kTaggedPrimitive);
   }
 
-  bool IsTaggedNumber() {
+  bool IsTaggedNumber() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kTaggedNumber) == kTaggedNumber);
   }
 
-  bool IsSmi() {
+  bool IsSmi() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kSmi) == kSmi);
   }
 
-  bool IsHeapNumber() {
+  bool IsHeapNumber() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kHeapNumber) == kHeapNumber);
   }
 
-  bool IsString() {
+  bool IsString() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kString) == kString);
   }
 
-  bool IsBoolean() {
+  bool IsBoolean() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kBoolean) == kBoolean);
   }
 
-  bool IsNonPrimitive() {
+  bool IsNonPrimitive() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kNonPrimitive) == kNonPrimitive);
   }
 
-  bool IsJSArray() {
+  bool IsJSArray() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kJSArray) == kJSArray);
   }
 
-  bool IsJSObject() {
+  bool IsJSObject() const {
     ASSERT(type_ != kUninitialized);
     return ((type_ & kJSObject) == kJSObject);
   }
 
-  bool IsUninitialized() {
+  bool IsUninitialized() const {
     return type_ == kUninitialized;
   }
 
-  bool IsHeapObject() {
+  bool IsHeapObject() const {
     ASSERT(type_ != kUninitialized);
     return IsHeapNumber() || IsString() || IsNonPrimitive();
   }
 
-  static HType TypeFromValue(Isolate* isolate, Handle<Object> value);
+  static HType TypeFromValue(Handle<Object> value);
 
   const char* ToString();
 
@@ -2791,7 +2792,10 @@
   virtual intptr_t Hashcode() {
     ASSERT_ALLOCATION_DISABLED;
     // Dereferencing to use the object's raw address for hashing is safe.
-    AllowHandleDereference allow_handle_deref(isolate());
+    HandleDereferenceGuard allow_handle_deref(isolate(),
+                                              HandleDereferenceGuard::ALLOW);
+    SLOW_ASSERT(Heap::RelocationLock::IsLocked(isolate()->heap()) ||
+                !isolate()->optimizing_compiler_thread()->IsOptimizerThread());
     intptr_t hash = 0;
     for (int i = 0; i < prototypes_.length(); i++) {
       hash = 17 * hash + reinterpret_cast<intptr_t>(*prototypes_[i]);
@@ -3069,8 +3073,17 @@
 class HConstant: public HTemplateInstruction<0> {
  public:
   HConstant(Handle<Object> handle, Representation r);
-  HConstant(int32_t value, Representation r);
-  HConstant(double value, Representation r);
+  HConstant(int32_t value,
+            Representation r,
+            Handle<Object> optional_handle = Handle<Object>::null());
+  HConstant(double value,
+            Representation r,
+            Handle<Object> optional_handle = Handle<Object>::null());
+  HConstant(Handle<Object> handle,
+            Representation r,
+            HType type,
+            bool is_internalized_string,
+            bool boolean_value);
 
   Handle<Object> handle() {
     if (handle_.is_null()) {
@@ -3098,8 +3111,9 @@
     Heap* heap = isolate()->heap();
     // We should have handled minus_zero_value and nan_value in the
     // has_double_value_ clause above.
-    // Dereferencing is safe to compare against singletons.
-    AllowHandleDereference allow_handle_deref(isolate());
+    // Dereferencing is safe to compare against immovable singletons.
+    HandleDereferenceGuard allow_handle_deref(isolate(),
+                                              HandleDereferenceGuard::ALLOW);
     ASSERT(*handle_ != heap->minus_zero_value());
     ASSERT(*handle_ != heap->nan_value());
     return *handle_ == heap->undefined_value() ||
@@ -3148,14 +3162,17 @@
   bool HasStringValue() const {
     if (has_double_value_ || has_int32_value_) return false;
     ASSERT(!handle_.is_null());
-    return handle_->IsString();
+    return type_from_value_.IsString();
   }
   Handle<String> StringValue() const {
     ASSERT(HasStringValue());
     return Handle<String>::cast(handle_);
   }
+  bool HasInternalizedStringValue() const {
+    return HasStringValue() && is_internalized_string_;
+  }
 
-  bool ToBoolean();
+  bool BooleanValue() const { return boolean_value_; }
 
   bool IsUint32() {
     return HasInteger32Value() && (Integer32Value() >= 0);
@@ -3172,7 +3189,10 @@
     } else {
       ASSERT(!handle_.is_null());
       // Dereferencing to use the object's raw address for hashing is safe.
-      AllowHandleDereference allow_handle_deref(isolate());
+      HandleDereferenceGuard allow_handle_deref(isolate(),
+                                                HandleDereferenceGuard::ALLOW);
+      SLOW_ASSERT(Heap::RelocationLock::IsLocked(isolate()->heap()) ||
+                 !isolate()->optimizing_compiler_thread()->IsOptimizerThread());
       hash = reinterpret_cast<intptr_t>(*handle_);
     }
 
@@ -3222,8 +3242,11 @@
   // not the converse.
   bool has_int32_value_ : 1;
   bool has_double_value_ : 1;
+  bool is_internalized_string_ : 1;  // TODO(yangguo): make this part of HType.
+  bool boolean_value_ : 1;
   int32_t int32_value_;
   double double_value_;
+  HType type_from_value_;
 };
 
 
@@ -4525,7 +4548,10 @@
   virtual intptr_t Hashcode() {
     ASSERT_ALLOCATION_DISABLED;
     // Dereferencing to use the object's raw address for hashing is safe.
-    AllowHandleDereference allow_handle_deref(isolate());
+    HandleDereferenceGuard allow_handle_deref(isolate(),
+                                              HandleDereferenceGuard::ALLOW);
+    SLOW_ASSERT(Heap::RelocationLock::IsLocked(isolate()->heap()) ||
+               !isolate()->optimizing_compiler_thread()->IsOptimizerThread());
     return reinterpret_cast<intptr_t>(*cell_);
   }
 
@@ -4629,7 +4655,6 @@
       : type_(type),
         flags_(flags) {
     ASSERT((flags & CAN_ALLOCATE_IN_OLD_DATA_SPACE) == 0);  // unimplemented
-    ASSERT((flags & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) == 0);  // unimplemented
     SetOperandAt(0, context);
     SetOperandAt(1, size);
     set_representation(Representation::Tagged());
@@ -4684,6 +4709,31 @@
 };
 
 
+class HInnerAllocatedObject: public HTemplateInstruction<1> {
+ public:
+  HInnerAllocatedObject(HValue* value, int offset)
+      : offset_(offset) {
+    ASSERT(value->IsAllocate());
+    SetOperandAt(0, value);
+    set_representation(Representation::Tagged());
+  }
+
+  HValue* base_object() { return OperandAt(0); }
+  int offset() { return offset_; }
+
+  virtual Representation RequiredInputRepresentation(int index) {
+    return Representation::Tagged();
+  }
+
+  virtual void PrintDataTo(StringStream* stream);
+
+  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
+
+ private:
+  int offset_;
+};
+
+
 inline bool StoringValueNeedsWriteBarrier(HValue* value) {
   return !value->type().IsBoolean()
       && !value->type().IsSmi()
@@ -4693,6 +4743,11 @@
 
 inline bool ReceiverObjectNeedsWriteBarrier(HValue* object,
                                             HValue* new_space_dominator) {
+  if (object->IsInnerAllocatedObject()) {
+    return ReceiverObjectNeedsWriteBarrier(
+        HInnerAllocatedObject::cast(object)->base_object(),
+        new_space_dominator);
+  }
   if (object != new_space_dominator) return true;
   if (object->IsFastLiteral()) return false;
   if (object->IsAllocateObject()) return false;
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 8499b99..9f63c17 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -505,7 +505,9 @@
 
 void HGraph::Verify(bool do_full_verify) const {
   // Allow dereferencing for debug mode verification.
-  AllowHandleDereference allow_handle_deref(isolate());
+  Heap::RelocationLock(isolate()->heap());
+  HandleDereferenceGuard allow_handle_deref(isolate(),
+                                            HandleDereferenceGuard::ALLOW);
   for (int i = 0; i < blocks_.length(); i++) {
     HBasicBlock* block = blocks_.at(i);
 
@@ -585,18 +587,6 @@
 #endif
 
 
-HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer,
-                               Handle<Object> value) {
-  if (!pointer->is_set()) {
-    HConstant* constant = new(zone()) HConstant(value,
-                                                Representation::Tagged());
-    constant->InsertAfter(GetConstantUndefined());
-    pointer->set(constant);
-  }
-  return pointer->get();
-}
-
-
 HConstant* HGraph::GetConstantInt32(SetOncePointer<HConstant>* pointer,
                                     int32_t value) {
   if (!pointer->is_set()) {
@@ -624,19 +614,27 @@
 }
 
 
-HConstant* HGraph::GetConstantTrue() {
-  return GetConstant(&constant_true_, isolate()->factory()->true_value());
+#define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value)                  \
+HConstant* HGraph::GetConstant##Name() {                                       \
+  if (!constant_##name##_.is_set()) {                                          \
+    HConstant* constant = new(zone()) HConstant(                               \
+        isolate()->factory()->name##_value(),                                  \
+        Representation::Tagged(),                                              \
+        htype,                                                                 \
+        false,                                                                 \
+        boolean_value);                                                        \
+    constant->InsertAfter(GetConstantUndefined());                             \
+    constant_##name##_.set(constant);                                          \
+  }                                                                            \
+  return constant_##name##_.get();                                             \
 }
 
 
-HConstant* HGraph::GetConstantFalse() {
-  return GetConstant(&constant_false_, isolate()->factory()->false_value());
-}
+DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true)
+DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false)
+DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false)
 
-
-HConstant* HGraph::GetConstantHole() {
-  return GetConstant(&constant_hole_, isolate()->factory()->the_hole_value());
-}
+#undef DEFINE_GET_CONSTANT
 
 
 HGraphBuilder::CheckBuilder::CheckBuilder(HGraphBuilder* builder, BailoutId id)
@@ -1075,6 +1073,11 @@
   total_size->ClearFlag(HValue::kCanOverflow);
 
   HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE;
+  // TODO(hpayer): add support for old data space
+  if (FLAG_pretenure_literals && !IsFastDoubleElementsKind(kind)) {
+    flags = static_cast<HAllocate::Flags>(
+        flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE);
+  }
   if (IsFastDoubleElementsKind(kind)) {
     flags = static_cast<HAllocate::Flags>(
         flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED);
@@ -3711,7 +3714,7 @@
   }
   if (value->IsConstant()) {
     HConstant* constant_value = HConstant::cast(value);
-    if (constant_value->ToBoolean()) {
+    if (constant_value->BooleanValue()) {
       builder->current_block()->Goto(if_true(), builder->function_state());
     } else {
       builder->current_block()->Goto(if_false(), builder->function_state());
@@ -3878,6 +3881,8 @@
 void HGraph::GlobalValueNumbering() {
   // Perform common subexpression elimination and loop-invariant code motion.
   if (FLAG_use_gvn) {
+    // We use objects' raw addresses for identification, so they must not move.
+    Heap::RelocationLock relocation_lock(isolate()->heap());
     HPhase phase("H_Global value numbering", this);
     HGlobalValueNumberer gvn(this, info());
     bool removed_side_effects = gvn.Analyze();
@@ -9241,8 +9246,8 @@
 
     if (left_value->IsConstant()) {
       HConstant* left_constant = HConstant::cast(left_value);
-      if ((is_logical_and && left_constant->ToBoolean()) ||
-          (!is_logical_and && !left_constant->ToBoolean())) {
+      if ((is_logical_and && left_constant->BooleanValue()) ||
+          (!is_logical_and && !left_constant->BooleanValue())) {
         Drop(1);  // left_value.
         CHECK_BAILOUT(VisitForValue(expr->right()));
       }
@@ -10578,13 +10583,17 @@
 
 
 void HTracer::TraceLithium(const char* name, LChunk* chunk) {
-  AllowHandleDereference allow_handle_deref(chunk->isolate());
+  ASSERT(!FLAG_parallel_recompilation);
+  HandleDereferenceGuard allow_handle_deref(chunk->isolate(),
+                                            HandleDereferenceGuard::ALLOW);
   Trace(name, chunk->graph(), chunk);
 }
 
 
 void HTracer::TraceHydrogen(const char* name, HGraph* graph) {
-  AllowHandleDereference allow_handle_deref(graph->isolate());
+  ASSERT(!FLAG_parallel_recompilation);
+  HandleDereferenceGuard allow_handle_deref(graph->isolate(),
+                                            HandleDereferenceGuard::ALLOW);
   Trace(name, graph, NULL);
 }
 
diff --git a/src/hydrogen.h b/src/hydrogen.h
index 47fd69d..a35d9a6 100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -386,8 +386,6 @@
   }
 
  private:
-  HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
-                         Handle<Object> value);
   HConstant* GetConstantInt32(SetOncePointer<HConstant>* pointer,
                               int32_t integer_value);
 
@@ -422,7 +420,7 @@
   SetOncePointer<HConstant> constant_minus1_;
   SetOncePointer<HConstant> constant_true_;
   SetOncePointer<HConstant> constant_false_;
-  SetOncePointer<HConstant> constant_hole_;
+  SetOncePointer<HConstant> constant_the_hole_;
   SetOncePointer<HArgumentsObject> arguments_object_;
 
   SetOncePointer<HBasicBlock> osr_loop_entry_;
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc
index 51e16fd..afb1c03 100644
--- a/src/ia32/builtins-ia32.cc
+++ b/src/ia32/builtins-ia32.cc
@@ -1033,12 +1033,7 @@
   if (initial_capacity > 0) {
     size += FixedArray::SizeFor(initial_capacity);
   }
-  __ AllocateInNewSpace(size,
-                        result,
-                        scratch2,
-                        scratch3,
-                        gc_required,
-                        TAG_OBJECT);
+  __ Allocate(size, result, scratch2, scratch3, gc_required, TAG_OBJECT);
 
   // Allocated the JSArray. Now initialize the fields except for the elements
   // array.
@@ -1618,12 +1613,12 @@
 
   // Allocate a JSValue and put the tagged pointer into eax.
   Label gc_required;
-  __ AllocateInNewSpace(JSValue::kSize,
-                        eax,  // Result.
-                        ecx,  // New allocation top (we ignore it).
-                        no_reg,
-                        &gc_required,
-                        TAG_OBJECT);
+  __ Allocate(JSValue::kSize,
+              eax,  // Result.
+              ecx,  // New allocation top (we ignore it).
+              no_reg,
+              &gc_required,
+              TAG_OBJECT);
 
   // Set the map.
   __ LoadGlobalFunctionInitialMap(edi, ecx);
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index 1b27540..88207c4 100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -145,7 +145,7 @@
   Counters* counters = masm->isolate()->counters();
 
   Label gc;
-  __ AllocateInNewSpace(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT);
+  __ Allocate(JSFunction::kSize, eax, ebx, ecx, &gc, TAG_OBJECT);
 
   __ IncrementCounter(counters->fast_new_closure_total(), 1);
 
@@ -273,8 +273,8 @@
   // Try to allocate the context in new space.
   Label gc;
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-  __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize,
-                        eax, ebx, ecx, &gc, TAG_OBJECT);
+  __ Allocate((length * kPointerSize) + FixedArray::kHeaderSize,
+              eax, ebx, ecx, &gc, TAG_OBJECT);
 
   // Get the function from the stack.
   __ mov(ecx, Operand(esp, 1 * kPointerSize));
@@ -321,8 +321,7 @@
   // Try to allocate the context in new space.
   Label gc;
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-  __ AllocateInNewSpace(FixedArray::SizeFor(length),
-                        eax, ebx, ecx, &gc, TAG_OBJECT);
+  __ Allocate(FixedArray::SizeFor(length), eax, ebx, ecx, &gc, TAG_OBJECT);
 
   // Get the function or sentinel from the stack.
   __ mov(ecx, Operand(esp, 1 * kPointerSize));
@@ -414,7 +413,7 @@
   if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
     flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
   }
-  __ AllocateInNewSpace(size, eax, ebx, edx, fail, flags);
+  __ Allocate(size, eax, ebx, edx, fail, flags);
 
   if (allocation_site_mode == TRACK_ALLOCATION_SITE) {
     __ mov(FieldOperand(eax, allocation_info_start),
@@ -3301,7 +3300,7 @@
 
   StubCompiler::GenerateLoadArrayLength(masm, edx, eax, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -3320,7 +3319,7 @@
 
   StubCompiler::GenerateLoadFunctionPrototype(masm, edx, eax, ebx, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -3340,7 +3339,7 @@
   StubCompiler::GenerateLoadStringLength(masm, edx, eax, ebx, &miss,
                                          support_wrapper_);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -3404,7 +3403,7 @@
 
   __ bind(&miss);
 
-  StubCompiler::GenerateStoreMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -6739,12 +6738,8 @@
   // Compare lengths -  strings up to min-length are equal.
   __ bind(&compare_lengths);
   __ test(length_delta, length_delta);
-#ifndef ENABLE_LATIN_1
-  __ j(not_zero, &result_not_equal, Label::kNear);
-#else
   Label length_not_equal;
   __ j(not_zero, &length_not_equal, Label::kNear);
-#endif
 
   // Result is EQUAL.
   STATIC_ASSERT(EQUAL == 0);
@@ -6753,19 +6748,13 @@
   __ ret(0);
 
   Label result_greater;
-#ifdef ENABLE_LATIN_1
   Label result_less;
   __ bind(&length_not_equal);
   __ j(greater, &result_greater, Label::kNear);
   __ jmp(&result_less, Label::kNear);
-#endif
   __ bind(&result_not_equal);
-#ifndef ENABLE_LATIN_1
-  __ j(greater, &result_greater, Label::kNear);
-#else
   __ j(above, &result_greater, Label::kNear);
   __ bind(&result_less);
-#endif
 
   // Result is LESS.
   __ Set(eax, Immediate(Smi::FromInt(LESS)));
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
index 25c5e65..ebc3a2b 100644
--- a/src/ia32/full-codegen-ia32.cc
+++ b/src/ia32/full-codegen-ia32.cc
@@ -1489,7 +1489,7 @@
   __ bind(&materialized);
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc
index 4ae6603..0cd5f1f 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -4195,6 +4195,13 @@
 }
 
 
+void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
+  Register result = ToRegister(instr->result());
+  Register base = ToRegister(instr->base_object());
+  __ lea(result, Operand(base, instr->offset()));
+}
+
+
 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   Register object = ToRegister(instr->object());
   Register value = ToRegister(instr->value());
@@ -5461,12 +5468,8 @@
   // the constructor's prototype changes, but instance size and property
   // counts remain unchanged (if slack tracking finished).
   ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
-  __ AllocateInNewSpace(instance_size,
-                        result,
-                        no_reg,
-                        scratch,
-                        deferred->entry(),
-                        TAG_OBJECT);
+  __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
+              TAG_OBJECT);
 
   __ bind(deferred->exit());
   if (FLAG_debug_code) {
@@ -5556,7 +5559,10 @@
   }
   if (instr->size()->IsConstantOperand()) {
     int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
-    __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags);
+    if (instr->hydrogen()->CanAllocateInOldPointerSpace()) {
+      flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_POINTER_SPACE);
+    }
+    __ Allocate(size, result, temp, no_reg, deferred->entry(), flags);
   } else {
     Register size = ToRegister(instr->size());
     __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags);
@@ -5795,7 +5801,7 @@
   // Allocate all objects that are part of the literal in one big
   // allocation. This avoids multiple limit checks.
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
@@ -5885,7 +5891,7 @@
   __ bind(&materialized);
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc
index 69a0e7f..4a380ef 100644
--- a/src/ia32/lithium-ia32.cc
+++ b/src/ia32/lithium-ia32.cc
@@ -292,6 +292,13 @@
 }
 
 
+void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
+  stream->Add(" = ");
+  base_object()->PrintTo(stream);
+  stream->Add(" + %d", offset());
+}
+
+
 void LCallConstantFunction::PrintDataTo(StringStream* stream) {
   stream->Add("#%d / ", arity());
 }
@@ -718,10 +725,12 @@
 LUnallocated* LChunkBuilder::TempRegister() {
   LUnallocated* operand =
       new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
-  operand->set_virtual_register(allocator_->GetVirtualRegister());
+  int vreg = allocator_->GetVirtualRegister();
   if (!allocator_->AllocationOk()) {
-    Abort("Not enough virtual registers (temps).");
+    Abort("Out of virtual registers while trying to allocate temp register.");
+    return NULL;
   }
+  operand->set_virtual_register(vreg);
   return operand;
 }
 
@@ -984,7 +993,7 @@
   if (value->EmitAtUses()) {
     ASSERT(value->IsConstant());
     ASSERT(!value->representation().IsDouble());
-    HBasicBlock* successor = HConstant::cast(value)->ToBoolean()
+    HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
         ? instr->FirstSuccessor()
         : instr->SecondSuccessor();
     return new(zone()) LGoto(successor->block_id());
@@ -1081,6 +1090,15 @@
 }
 
 
+LInstruction* LChunkBuilder::DoInnerAllocatedObject(
+    HInnerAllocatedObject* inner_object) {
+  LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
+  LInnerAllocatedObject* result =
+    new(zone()) LInnerAllocatedObject(base_object);
+  return DefineAsRegister(result);
+}
+
+
 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
   return instr->HasNoUses()
       ? NULL
diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h
index 318a51f..0e36474 100644
--- a/src/ia32/lithium-ia32.h
+++ b/src/ia32/lithium-ia32.h
@@ -184,7 +184,8 @@
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
   V(WrapReceiver)                               \
-  V(Drop)
+  V(Drop)                                       \
+  V(InnerAllocatedObject)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -1681,6 +1682,22 @@
 };
 
 
+class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
+ public:
+  explicit LInnerAllocatedObject(LOperand* base_object) {
+    inputs_[0] = base_object;
+  }
+
+  LOperand* base_object() { return inputs_[0]; }
+  int offset() { return hydrogen()->offset(); }
+
+  virtual void PrintDataTo(StringStream* stream);
+
+  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
+  DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
+};
+
+
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc
index 494a1bf..debf64a 100644
--- a/src/ia32/macro-assembler-ia32.cc
+++ b/src/ia32/macro-assembler-ia32.cc
@@ -618,6 +618,7 @@
 
 
 void MacroAssembler::DispatchMap(Register obj,
+                                 Register unused,
                                  Handle<Map> map,
                                  Handle<Code> success,
                                  SmiCheckType smi_check_type) {
@@ -1214,8 +1215,8 @@
 void MacroAssembler::LoadAllocationTopHelper(Register result,
                                              Register scratch,
                                              AllocationFlags flags) {
-  ExternalReference new_space_allocation_top =
-      ExternalReference::new_space_allocation_top_address(isolate());
+  ExternalReference allocation_top =
+      AllocationUtils::GetAllocationTopReference(isolate(), flags);
 
   // Just return if allocation top is already known.
   if ((flags & RESULT_CONTAINS_TOP) != 0) {
@@ -1223,7 +1224,7 @@
     ASSERT(scratch.is(no_reg));
 #ifdef DEBUG
     // Assert that result actually contains top on entry.
-    cmp(result, Operand::StaticVariable(new_space_allocation_top));
+    cmp(result, Operand::StaticVariable(allocation_top));
     Check(equal, "Unexpected allocation top");
 #endif
     return;
@@ -1231,39 +1232,40 @@
 
   // Move address of new object to result. Use scratch register if available.
   if (scratch.is(no_reg)) {
-    mov(result, Operand::StaticVariable(new_space_allocation_top));
+    mov(result, Operand::StaticVariable(allocation_top));
   } else {
-    mov(scratch, Immediate(new_space_allocation_top));
+    mov(scratch, Immediate(allocation_top));
     mov(result, Operand(scratch, 0));
   }
 }
 
 
 void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
-                                               Register scratch) {
+                                               Register scratch,
+                                               AllocationFlags flags) {
   if (emit_debug_code()) {
     test(result_end, Immediate(kObjectAlignmentMask));
     Check(zero, "Unaligned allocation in new space");
   }
 
-  ExternalReference new_space_allocation_top =
-      ExternalReference::new_space_allocation_top_address(isolate());
+  ExternalReference allocation_top =
+      AllocationUtils::GetAllocationTopReference(isolate(), flags);
 
   // Update new top. Use scratch if available.
   if (scratch.is(no_reg)) {
-    mov(Operand::StaticVariable(new_space_allocation_top), result_end);
+    mov(Operand::StaticVariable(allocation_top), result_end);
   } else {
     mov(Operand(scratch, 0), result_end);
   }
 }
 
 
-void MacroAssembler::AllocateInNewSpace(int object_size,
-                                        Register result,
-                                        Register result_end,
-                                        Register scratch,
-                                        Label* gc_required,
-                                        AllocationFlags flags) {
+void MacroAssembler::Allocate(int object_size,
+                              Register result,
+                              Register result_end,
+                              Register scratch,
+                              Label* gc_required,
+                              AllocationFlags flags) {
   ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
@@ -1287,6 +1289,7 @@
   // Align the next allocation. Storing the filler map without checking top is
   // always safe because the limit of the heap is always aligned.
   if ((flags & DOUBLE_ALIGNMENT) != 0) {
+    ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
     ASSERT(kPointerAlignment * 2 == kDoubleAlignment);
     Label aligned;
     test(result, Immediate(kDoubleAlignmentMask));
@@ -1299,20 +1302,20 @@
 
   Register top_reg = result_end.is_valid() ? result_end : result;
 
-  // Calculate new top and bail out if new space is exhausted.
-  ExternalReference new_space_allocation_limit =
-      ExternalReference::new_space_allocation_limit_address(isolate());
+  // Calculate new top and bail out if space is exhausted.
+  ExternalReference allocation_limit =
+      AllocationUtils::GetAllocationLimitReference(isolate(), flags);
 
   if (!top_reg.is(result)) {
     mov(top_reg, result);
   }
   add(top_reg, Immediate(object_size));
   j(carry, gc_required);
-  cmp(top_reg, Operand::StaticVariable(new_space_allocation_limit));
+  cmp(top_reg, Operand::StaticVariable(allocation_limit));
   j(above, gc_required);
 
   // Update allocation top.
-  UpdateAllocationTopHelper(top_reg, scratch);
+  UpdateAllocationTopHelper(top_reg, scratch, flags);
 
   // Tag result if requested.
   bool tag_result = (flags & TAG_OBJECT) != 0;
@@ -1340,6 +1343,7 @@
     Label* gc_required,
     AllocationFlags flags) {
   ASSERT((flags & SIZE_IN_WORDS) == 0);
+  ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -1399,7 +1403,7 @@
   }
 
   // Update allocation top.
-  UpdateAllocationTopHelper(result_end, scratch);
+  UpdateAllocationTopHelper(result_end, scratch, flags);
 }
 
 
@@ -1410,6 +1414,7 @@
                                         Label* gc_required,
                                         AllocationFlags flags) {
   ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
+  ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -1459,7 +1464,7 @@
   }
 
   // Update allocation top.
-  UpdateAllocationTopHelper(result_end, scratch);
+  UpdateAllocationTopHelper(result_end, scratch, flags);
 }
 
 
@@ -1482,12 +1487,8 @@
                                         Register scratch2,
                                         Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(HeapNumber::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(HeapNumber::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1575,12 +1576,8 @@
   ASSERT(length > 0);
 
   // Allocate ASCII string in new space.
-  AllocateInNewSpace(SeqOneByteString::SizeFor(length),
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SeqOneByteString::SizeFor(length), result, scratch1, scratch2,
+           gc_required, TAG_OBJECT);
 
   // Set the map, length and hash field.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1597,12 +1594,8 @@
                                         Register scratch2,
                                         Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1615,12 +1608,8 @@
                                              Register scratch2,
                                              Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1633,12 +1622,8 @@
                                           Register scratch2,
                                           Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1651,12 +1636,8 @@
                                                Register scratch2,
                                                Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   mov(FieldOperand(result, HeapObject::kMapOffset),
@@ -1830,7 +1811,8 @@
 
 
 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
+  ASSERT(allow_stub_calls_ ||
+         stub->CompilingCallsToThisStubIsGCSafe(isolate()));
   jmp(stub->GetCode(isolate()), RelocInfo::CODE_TARGET);
 }
 
@@ -1843,7 +1825,7 @@
 
 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate());
 }
 
 
diff --git a/src/ia32/macro-assembler-ia32.h b/src/ia32/macro-assembler-ia32.h
index 05ad82d..8dd4120 100644
--- a/src/ia32/macro-assembler-ia32.h
+++ b/src/ia32/macro-assembler-ia32.h
@@ -410,6 +410,7 @@
   // specified target if equal. Skip the smi check if not required (object is
   // known to be a heap object)
   void DispatchMap(Register obj,
+                   Register unused,
                    Handle<Map> map,
                    Handle<Code> success,
                    SmiCheckType smi_check_type);
@@ -564,22 +565,22 @@
   // ---------------------------------------------------------------------------
   // Allocation support
 
-  // Allocate an object in new space. If the new space is exhausted control
-  // continues at the gc_required label. The allocated object is returned in
-  // result and end of the new object is returned in result_end. The register
-  // scratch can be passed as no_reg in which case an additional object
-  // reference will be added to the reloc info. The returned pointers in result
-  // and result_end have not yet been tagged as heap objects. If
-  // result_contains_top_on_entry is true the content of result is known to be
-  // the allocation top on entry (could be result_end from a previous call to
-  // AllocateInNewSpace). If result_contains_top_on_entry is true scratch
+  // Allocate an object in new space or old pointer space. If the given space
+  // is exhausted control continues at the gc_required label. The allocated
+  // object is returned in result and end of the new object is returned in
+  // result_end. The register scratch can be passed as no_reg in which case
+  // an additional object reference will be added to the reloc info. The
+  // returned pointers in result and result_end have not yet been tagged as
+  // heap objects. If result_contains_top_on_entry is true the content of
+  // result is known to be the allocation top on entry (could be result_end
+  // from a previous call). If result_contains_top_on_entry is true scratch
   // should be no_reg as it is never used.
-  void AllocateInNewSpace(int object_size,
-                          Register result,
-                          Register result_end,
-                          Register scratch,
-                          Label* gc_required,
-                          AllocationFlags flags);
+  void Allocate(int object_size,
+                Register result,
+                Register result_end,
+                Register scratch,
+                Label* gc_required,
+                AllocationFlags flags);
 
   void AllocateInNewSpace(int header_size,
                           ScaleFactor element_size,
@@ -910,7 +911,10 @@
   void LoadAllocationTopHelper(Register result,
                                Register scratch,
                                AllocationFlags flags);
-  void UpdateAllocationTopHelper(Register result_end, Register scratch);
+
+  void UpdateAllocationTopHelper(Register result_end,
+                                 Register scratch,
+                                 AllocationFlags flags);
 
   // Helper for PopHandleScope.  Allowed to perform a GC and returns
   // NULL if gc_allowed.  Does not perform a GC if !gc_allowed, and
diff --git a/src/ia32/regexp-macro-assembler-ia32.cc b/src/ia32/regexp-macro-assembler-ia32.cc
index bb0e0ad..d8f2e8f 100644
--- a/src/ia32/regexp-macro-assembler-ia32.cc
+++ b/src/ia32/regexp-macro-assembler-ia32.cc
@@ -344,9 +344,6 @@
     __ or_(eax, 0x20);  // Convert match character to lower-case.
     __ lea(ecx, Operand(eax, -'a'));
     __ cmp(ecx, static_cast<int32_t>('z' - 'a'));  // Is eax a lowercase letter?
-#ifndef ENABLE_LATIN_1
-    __ j(above, &fail);  // Weren't letters anyway.
-#else
     Label convert_capture;
     __ j(below_equal, &convert_capture);  // In range 'a'-'z'.
     // Latin-1: Check for values in range [224,254] but not 247.
@@ -356,7 +353,6 @@
     __ cmp(ecx, Immediate(247 - 224));  // Check for 247.
     __ j(equal, &fail);
     __ bind(&convert_capture);
-#endif
     // Also convert capture character.
     __ movzx_b(ecx, Operand(edx, 0));
     __ or_(ecx, 0x20);
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index d0b7881..f7e795e 100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -369,19 +369,6 @@
 }
 
 
-// Load a fast property out of a holder object (src). In-object properties
-// are loaded directly otherwise the property is loaded from the properties
-// fixed array.
-void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
-                                            Register dst,
-                                            Register src,
-                                            Handle<JSObject> holder,
-                                            PropertyIndex index) {
-  DoGenerateFastPropertyLoad(
-      masm, dst, src, index.is_inobject(holder), index.translate(holder));
-}
-
-
 void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm,
                                               Register dst,
                                               Register src,
@@ -729,28 +716,13 @@
 };
 
 
-void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
-  Handle<Code> code = (kind == Code::LOAD_IC)
-      ? masm->isolate()->builtins()->LoadIC_Miss()
-      : masm->isolate()->builtins()->KeyedLoadIC_Miss();
-  __ jmp(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
-  Handle<Code> code = (kind == Code::STORE_IC)
-      ? masm->isolate()->builtins()->StoreIC_Miss()
-      : masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) {
-  Handle<Code> code =
-      masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ jmp(code, RelocInfo::CODE_TARGET);
+void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
+                                                Label* label,
+                                                Handle<Name> name) {
+  if (!label->is_unused()) {
+    __ bind(label);
+    __ mov(this->name(), Immediate(name));
+  }
 }
 
 
@@ -763,9 +735,11 @@
                                       Handle<Name> name,
                                       Register receiver_reg,
                                       Register name_reg,
+                                      Register value_reg,
                                       Register scratch1,
                                       Register scratch2,
-                                      Label* miss_label) {
+                                      Label* miss_label,
+                                      Label* miss_restore_name) {
   LookupResult lookup(masm->isolate());
   object->Lookup(*name, &lookup);
   if (lookup.IsFound() && (lookup.IsReadOnly() || !lookup.IsCacheable())) {
@@ -800,16 +774,8 @@
       } while (holder->GetPrototype()->IsJSObject());
     }
     // We need an extra register, push
-    __ push(name_reg);
-    Label miss_pop, done_check;
     CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
-                    scratch1, scratch2, name, &miss_pop);
-    __ jmp(&done_check);
-    __ bind(&miss_pop);
-    __ pop(name_reg);
-    __ jmp(miss_label);
-    __ bind(&done_check);
-    __ pop(name_reg);
+                    scratch1, scratch2, name, miss_restore_name);
   }
 
   // Stub never generated for non-global objects that require access
@@ -857,11 +823,11 @@
   if (index < 0) {
     // Set the property straight into the object.
     int offset = object->map()->instance_size() + (index * kPointerSize);
-    __ mov(FieldOperand(receiver_reg, offset), eax);
+    __ mov(FieldOperand(receiver_reg, offset), value_reg);
 
     // Update the write barrier for the array address.
     // Pass the value being stored in the now unused name_reg.
-    __ mov(name_reg, eax);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(receiver_reg,
                         offset,
                         name_reg,
@@ -876,7 +842,7 @@
 
     // Update the write barrier for the array address.
     // Pass the value being stored in the now unused name_reg.
-    __ mov(name_reg, eax);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(scratch1,
                         offset,
                         name_reg,
@@ -885,6 +851,7 @@
   }
 
   // Return the value (register eax).
+  ASSERT(value_reg.is(eax));
   __ ret(0);
 }
 
@@ -933,15 +900,16 @@
   }
 }
 
-#undef __
-#define __ ACCESS_MASM(masm())
 
-
-void StubCompiler::GenerateTailCall(Handle<Code> code) {
+void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
   __ jmp(code, RelocInfo::CODE_TARGET);
 }
 
 
+#undef __
+#define __ ACCESS_MASM(masm())
+
+
 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
                                        Register object_reg,
                                        Handle<JSObject> holder,
@@ -1062,7 +1030,7 @@
   if (!miss->is_unused()) {
     __ jmp(success);
     __ bind(miss);
-    GenerateLoadMiss(masm(), kind());
+    TailCallBuiltin(masm(), MissBuiltin(kind()));
   }
 }
 
@@ -2581,66 +2549,27 @@
 }
 
 
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                  int index,
-                                                  Handle<Map> transition,
-                                                  Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : name
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-  Label miss;
-
-  // Generate store field code.  Trashes the name register.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     edx, ecx, ebx, edi,
-                     &miss);
-  // Handle store cache miss.
-  __ bind(&miss);
-  __ mov(ecx, Immediate(name));  // restore name
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreCallback(
     Handle<Name> name,
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<JSObject> holder,
     Handle<ExecutableAccessorInfo> callback) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : name
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-  Label miss;
+  Label miss, miss_restore_name;
   // Check that the maps haven't changed, preserving the value register.
-  __ push(eax);
-  __ JumpIfSmi(edx, &miss);
-  CheckPrototypes(receiver, edx, holder, ebx, eax, edi, name, &miss);
-  __ pop(eax);  // restore value
+  __ JumpIfSmi(receiver(), &miss);
+  CheckPrototypes(object, receiver(), holder,
+                  scratch1(), this->name(), scratch2(),
+                  name, &miss_restore_name);
 
   // Stub never generated for non-global objects that require access checks.
   ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
 
-  __ pop(ebx);  // remove the return address
-  __ push(edx);  // receiver
-  __ push(Immediate(callback));  // callback info
-  __ push(ecx);  // name
-  __ push(eax);  // value
-  __ push(ebx);  // restore return address
+  __ pop(scratch1());  // remove the return address
+  __ push(receiver());
+  __ Push(callback);
+  __ Push(name);
+  __ push(value());
+  __ push(scratch1());  // restore return address
 
   // Do tail-call to the runtime system.
   ExternalReference store_callback_property =
@@ -2648,13 +2577,12 @@
   __ TailCallExternalReference(store_callback_property, 4, 1);
 
   // Handle store cache miss.
+  GenerateRestoreName(masm(), &miss_restore_name, name);
   __ bind(&miss);
-  __ pop(eax);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
+  return GetICCode(kind(), Code::CALLBACKS, name);
 }
 
 
@@ -2704,67 +2632,30 @@
 #define __ ACCESS_MASM(masm())
 
 
-Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
-    Handle<Name> name,
-    Handle<JSObject> receiver,
-    Handle<JSObject> holder,
-    Handle<JSFunction> setter) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : name
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-  Label miss;
-
-  // Check that the maps haven't changed, preserving the name register.
-  __ push(ecx);
-  __ JumpIfSmi(edx, &miss);
-  CheckPrototypes(receiver, edx, holder, ebx, ecx, edi, name, &miss);
-  __ pop(ecx);
-
-  GenerateStoreViaSetter(masm(), setter);
-
-  __ bind(&miss);
-  __ pop(ecx);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : name
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the object hasn't changed.
-  __ CheckMap(edx, Handle<Map>(receiver->map()),
+  __ CheckMap(receiver(), Handle<Map>(object->map()),
               &miss, DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS);
 
   // Perform global security token check if needed.
-  if (receiver->IsJSGlobalProxy()) {
+  if (object->IsJSGlobalProxy()) {
     __ CheckAccessGlobalProxy(edx, ebx, &miss);
   }
 
   // Stub never generated for non-global objects that require access
   // checks.
-  ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded());
+  ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
 
-  __ pop(ebx);  // remove the return address
-  __ push(edx);  // receiver
-  __ push(ecx);  // name
-  __ push(eax);  // value
-  __ push(Immediate(Smi::FromInt(strict_mode_)));
-  __ push(ebx);  // restore return address
+  __ pop(scratch1());  // remove the return address
+  __ push(receiver());
+  __ push(this->name());
+  __ push(value());
+  __ push(Immediate(Smi::FromInt(strict_mode())));
+  __ push(scratch1());  // restore return address
 
   // Do tail-call to the runtime system.
   ExternalReference store_ic_property =
@@ -2773,11 +2664,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::INTERCEPTOR, name);
+  return GetICCode(kind(), Code::INTERCEPTOR, name);
 }
 
 
@@ -2785,22 +2675,17 @@
     Handle<GlobalObject> object,
     Handle<JSGlobalPropertyCell> cell,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : name
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the global has not changed.
-  __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
+  __ cmp(FieldOperand(receiver(), HeapObject::kMapOffset),
          Immediate(Handle<Map>(object->map())));
   __ j(not_equal, &miss);
 
   // Compute the cell operand to use.
-  __ mov(ebx, Immediate(cell));
-  Operand cell_operand = FieldOperand(ebx, JSGlobalPropertyCell::kValueOffset);
+  __ mov(scratch1(), Immediate(cell));
+  Operand cell_operand =
+      FieldOperand(scratch1(), JSGlobalPropertyCell::kValueOffset);
 
   // Check that the value in the cell is not the hole. If it is, this
   // cell could have been deleted and reintroducing the global needs
@@ -2810,7 +2695,7 @@
   __ j(equal, &miss);
 
   // Store the value in the cell.
-  __ mov(cell_operand, eax);
+  __ mov(cell_operand, value());
   // No write barrier here, because cells are always rescanned.
 
   // Return the value (register eax).
@@ -2821,77 +2706,10 @@
   // Handle store cache miss.
   __ bind(&miss);
   __ IncrementCounter(counters->named_store_global_inline_miss(), 1);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                       int index,
-                                                       Handle<Map> transition,
-                                                       Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : key
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-  Label miss;
-
-  Counters* counters = isolate()->counters();
-  __ IncrementCounter(counters->keyed_store_field(), 1);
-
-  // Check that the name has not changed.
-  __ cmp(ecx, Immediate(name));
-  __ j(not_equal, &miss);
-
-  // Generate store field code.  Trashes the name register.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     edx, ecx, ebx, edi,
-                     &miss);
-
-  // Handle store cache miss.
-  __ bind(&miss);
-  __ DecrementCounter(counters->keyed_store_field(), 1);
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : key
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
-  Handle<Code> stub =
-      KeyedStoreElementStub(is_jsarray,
-                            elements_kind,
-                            store_mode_).GetCode(isolate());
-
-  __ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
-
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string());
+  return GetICCode(kind(), Code::NORMAL, name);
 }
 
 
@@ -2899,34 +2717,27 @@
     MapHandleList* receiver_maps,
     CodeHandleList* handler_stubs,
     MapHandleList* transitioned_maps) {
-  // ----------- S t a t e -------------
-  //  -- eax    : value
-  //  -- ecx    : key
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
   Label miss;
-  __ JumpIfSmi(edx, &miss, Label::kNear);
-  __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
-  // ebx: receiver->map().
+  __ JumpIfSmi(receiver(), &miss, Label::kNear);
+  __ mov(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
   for (int i = 0; i < receiver_maps->length(); ++i) {
-    __ cmp(edi, receiver_maps->at(i));
+    __ cmp(scratch1(), receiver_maps->at(i));
     if (transitioned_maps->at(i).is_null()) {
       __ j(equal, handler_stubs->at(i));
     } else {
       Label next_map;
       __ j(not_equal, &next_map, Label::kNear);
-      __ mov(ebx, Immediate(transitioned_maps->at(i)));
+      __ mov(transition_map(), Immediate(transitioned_maps->at(i)));
       __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
       __ bind(&next_map);
     }
   }
   __ bind(&miss);
-  Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
+  return GetICCode(
+      kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
 }
 
 
@@ -2964,6 +2775,20 @@
 }
 
 
+Register* StoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { edx, ecx, eax, ebx, edi, no_reg };
+  return registers;
+}
+
+
+Register* KeyedStoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { edx, ecx, eax, ebx, edi, no_reg };
+  return registers;
+}
+
+
 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
                                               Register name_reg,
                                               Label* miss) {
@@ -2972,6 +2797,14 @@
 }
 
 
+void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name,
+                                               Register name_reg,
+                                               Label* miss) {
+  __ cmp(name_reg, Immediate(name));
+  __ j(not_equal, miss);
+}
+
+
 #undef __
 #define __ ACCESS_MASM(masm)
 
@@ -3050,34 +2883,6 @@
 }
 
 
-Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- ecx    : key
-  //  -- edx    : receiver
-  //  -- esp[0] : return address
-  // -----------------------------------
-
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  if (receiver_map->has_fast_elements() ||
-      receiver_map->has_external_array_elements()) {
-    Handle<Code> stub = KeyedLoadFastElementStub(
-        receiver_map->instance_type() == JS_ARRAY_TYPE,
-        elements_kind).GetCode(isolate());
-    __ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
-  } else {
-    Handle<Code> stub =
-        KeyedLoadDictionaryElementStub().GetCode(isolate());
-    __ DispatchMap(edx, receiver_map, stub, DO_SMI_CHECK);
-  }
-
-  GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
-
-  // Return the generated code.
-  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
-}
-
-
 Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC(
     MapHandleList* receiver_maps,
     CodeHandleList* handlers,
@@ -3100,7 +2905,7 @@
   }
 
   __ bind(&miss);
-  GenerateLoadMiss(masm(), kind());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   InlineCacheState state =
@@ -3156,8 +2961,8 @@
   __ cmp(ecx, Immediate(instance_size));
   __ Check(equal, "Instance size of initial map changed.");
 #endif
-  __ AllocateInNewSpace(instance_size, edx, ecx, no_reg,
-                        &generic_stub_call, NO_ALLOCATION_FLAGS);
+  __ Allocate(instance_size, edx, ecx, no_reg, &generic_stub_call,
+              NO_ALLOCATION_FLAGS);
 
   // Allocated the JSObject, now initialize the fields and add the heap tag.
   // ebx: initial map
@@ -3284,10 +3089,7 @@
   //  -- edx    : receiver
   //  -- esp[0] : return address
   // -----------------------------------
-
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_Slow();
-  __ jmp(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow);
 
   __ bind(&miss_force_generic);
   // ----------- S t a t e -------------
@@ -3295,10 +3097,7 @@
   //  -- edx    : receiver
   //  -- esp[0] : return address
   // -----------------------------------
-
-  Handle<Code> miss_force_generic_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ jmp(miss_force_generic_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
 }
 
 
@@ -3516,9 +3315,7 @@
   //  -- edx    : receiver
   //  -- esp[0] : return address
   // -----------------------------------
-
-  Handle<Code> ic = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
 
   // ----------- S t a t e -------------
   //  -- eax    : value
@@ -3528,9 +3325,7 @@
   // -----------------------------------
 
   __ bind(&miss_force_generic);
-  Handle<Code> miss_ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 }
 
 
@@ -3606,14 +3401,11 @@
 
   // Handle store cache miss, replacing the ic with the generic stub.
   __ bind(&miss_force_generic);
-  Handle<Code> ic_force_generic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   // Handle transition to other elements kinds without using the generic stub.
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Handle transition requiring the array to grow.
@@ -3631,7 +3423,7 @@
     __ j(not_equal, &check_capacity);
 
     int size = FixedArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, edi, ebx, ecx, &prepare_slow, TAG_OBJECT);
+    __ Allocate(size, edi, ebx, ecx, &prepare_slow, TAG_OBJECT);
     // Restore the key, which is known to be the array length.
 
     // eax: value
@@ -3684,8 +3476,7 @@
     __ mov(ecx, Immediate(0));
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
@@ -3734,14 +3525,11 @@
 
   // Handle store cache miss, replacing the ic with the generic stub.
   __ bind(&miss_force_generic);
-  Handle<Code> ic_force_generic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   // Handle transition to other elements kinds without using the generic stub.
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Handle transition requiring the array to grow.
@@ -3767,7 +3555,7 @@
     __ j(not_equal, &check_capacity);
 
     int size = FixedDoubleArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, edi, ebx, ecx, &prepare_slow, TAG_OBJECT);
+    __ Allocate(size, edi, ebx, ecx, &prepare_slow, TAG_OBJECT);
 
     // Restore the key, which is known to be the array length.
     __ mov(ecx, Immediate(0));
@@ -3822,8 +3610,7 @@
     __ mov(ecx, Immediate(0));
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
diff --git a/src/isolate.cc b/src/isolate.cc
index 5f7b3f2..fb9cab1 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -944,11 +944,7 @@
   if (decision != UNKNOWN) return decision == YES;
 
   // Get named access check callback
-  // TODO(dcarney): revert
-  Map* map = receiver->map();
-  CHECK(map->IsMap());
-  CHECK(map->constructor()->IsJSFunction());
-  JSFunction* constructor = JSFunction::cast(map->constructor());
+  JSFunction* constructor = JSFunction::cast(receiver->map()->constructor());
   if (!constructor->shared()->IsApiFunction()) return false;
 
   Object* data_obj =
@@ -1713,7 +1709,8 @@
   memset(code_kind_statistics_, 0,
          sizeof(code_kind_statistics_[0]) * Code::NUMBER_OF_KINDS);
 
-  allow_handle_deref_ = true;
+  allow_compiler_thread_handle_deref_ = true;
+  allow_execution_thread_handle_deref_ = true;
 #endif
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
@@ -2321,6 +2318,33 @@
 }
 
 
+#ifdef DEBUG
+bool Isolate::AllowHandleDereference() {
+  if (allow_execution_thread_handle_deref_ &&
+      allow_compiler_thread_handle_deref_) {
+    // Short-cut to avoid polling thread id.
+    return true;
+  }
+  if (FLAG_parallel_recompilation &&
+      optimizing_compiler_thread()->IsOptimizerThread()) {
+    return allow_compiler_thread_handle_deref_;
+  } else {
+    return allow_execution_thread_handle_deref_;
+  }
+}
+
+
+void Isolate::SetAllowHandleDereference(bool allow) {
+  if (FLAG_parallel_recompilation &&
+      optimizing_compiler_thread()->IsOptimizerThread()) {
+    allow_compiler_thread_handle_deref_ = allow;
+  } else {
+    allow_execution_thread_handle_deref_ = allow;
+  }
+}
+#endif
+
+
 HStatistics* Isolate::GetHStatistics() {
   if (hstatistics() == NULL) set_hstatistics(new HStatistics());
   return hstatistics();
diff --git a/src/isolate.h b/src/isolate.h
index e6f6d16..d6770cc 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -988,8 +988,9 @@
 
   int* code_kind_statistics() { return code_kind_statistics_; }
 
-  bool allow_handle_deref() { return allow_handle_deref_; }
-  void set_allow_handle_deref(bool allow) { allow_handle_deref_ = allow; }
+  bool AllowHandleDereference();
+
+  void SetAllowHandleDereference(bool allow);
 #endif
 
 #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
@@ -1305,7 +1306,8 @@
   JSObject::SpillInformation js_spill_information_;
   int code_kind_statistics_[Code::NUMBER_OF_KINDS];
 
-  bool allow_handle_deref_;
+  bool allow_compiler_thread_handle_deref_;
+  bool allow_execution_thread_handle_deref_;
 #endif
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index e73b1d4..b490521 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -2512,11 +2512,7 @@
     // For 2-character preloads in ASCII mode or 1-character preloads in
     // TWO_BYTE mode we also use a 16 bit load with zero extend.
     if (details->characters() == 2 && compiler->ascii()) {
-#ifndef ENABLE_LATIN_1
-      if ((mask & 0x7f7f) == 0xffff) need_mask = false;
-#else
       if ((mask & 0xffff) == 0xffff) need_mask = false;
-#endif
     } else if (details->characters() == 1 && !compiler->ascii()) {
       if ((mask & 0xffff) == 0xffff) need_mask = false;
     } else {
@@ -2794,17 +2790,12 @@
 
 // We need to check for the following characters: 0x39c 0x3bc 0x178.
 static inline bool RangeContainsLatin1Equivalents(CharacterRange range) {
-#ifdef ENABLE_LATIN_1
   // TODO(dcarney): this could be a lot more efficient.
   return range.Contains(0x39c) ||
       range.Contains(0x3bc) || range.Contains(0x178);
-#else
-  return false;
-#endif
 }
 
 
-#ifdef ENABLE_LATIN_1
 static bool RangesContainLatin1Equivalents(ZoneList<CharacterRange>* ranges) {
   for (int i = 0; i < ranges->length(); i++) {
     // TODO(dcarney): this could be a lot more efficient.
@@ -2812,7 +2803,6 @@
   }
   return false;
 }
-#endif
 
 
 RegExpNode* TextNode::FilterASCII(int depth, bool ignore_case) {
@@ -2826,11 +2816,6 @@
     if (elm.type == TextElement::ATOM) {
       Vector<const uc16> quarks = elm.data.u_atom->data();
       for (int j = 0; j < quarks.length(); j++) {
-#ifndef ENABLE_LATIN_1
-        if (quarks[j] > String::kMaxOneByteCharCode) {
-          return set_replacement(NULL);
-        }
-#else
         uint16_t c = quarks[j];
         if (c <= String::kMaxOneByteCharCode) continue;
         if (!ignore_case) return set_replacement(NULL);
@@ -2842,7 +2827,6 @@
         // Convert quark to Latin-1 in place.
         uint16_t* copy = const_cast<uint16_t*>(quarks.start());
         copy[j] = converted;
-#endif
       }
     } else {
       ASSERT(elm.type == TextElement::CHAR_CLASS);
@@ -2857,19 +2841,15 @@
         if (range_count != 0 &&
             ranges->at(0).from() == 0 &&
             ranges->at(0).to() >= String::kMaxOneByteCharCode) {
-#ifdef ENABLE_LATIN_1
           // This will be handled in a later filter.
           if (ignore_case && RangesContainLatin1Equivalents(ranges)) continue;
-#endif
           return set_replacement(NULL);
         }
       } else {
         if (range_count == 0 ||
             ranges->at(0).from() > String::kMaxOneByteCharCode) {
-#ifdef ENABLE_LATIN_1
           // This will be handled in a later filter.
           if (ignore_case && RangesContainLatin1Equivalents(ranges)) continue;
-#endif
           return set_replacement(NULL);
         }
       }
diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc
index e3b9a88..6ee9ef2 100644
--- a/src/lithium-allocator.cc
+++ b/src/lithium-allocator.cc
@@ -839,8 +839,9 @@
         ASSERT(!cur_input->IsUsedAtStart());
 
         LUnallocated* input_copy = cur_input->CopyUnconstrained(zone());
-        cur_input->set_virtual_register(GetVirtualRegister());
+        int vreg = GetVirtualRegister();
         if (!AllocationOk()) return;
+        cur_input->set_virtual_register(vreg);
 
         if (RequiredRegisterKind(input_copy->virtual_register()) ==
             DOUBLE_REGISTERS) {
@@ -1924,6 +1925,7 @@
     LiveRange* tail = SplitBetween(current,
                                    current->Start(),
                                    block_pos[reg].InstructionStart());
+    if (!AllocationOk()) return;
     AddToUnhandledSorted(tail);
   }
 
@@ -1954,6 +1956,7 @@
       } else {
         SpillBetween(range, split_pos, next_pos->pos());
       }
+      if (!AllocationOk()) return;
       ActiveToHandled(range);
       --i;
     }
@@ -1972,6 +1975,7 @@
           next_intersection = Min(next_intersection, next_pos->pos());
           SpillBetween(range, split_pos, next_intersection);
         }
+        if (!AllocationOk()) return;
         InactiveToHandled(range);
         --i;
       }
@@ -1997,8 +2001,9 @@
   ASSERT(pos.IsInstructionStart() ||
          !chunk_->instructions()->at(pos.InstructionIndex())->IsControl());
 
-  LiveRange* result = LiveRangeFor(GetVirtualRegister());
+  int vreg = GetVirtualRegister();
   if (!AllocationOk()) return NULL;
+  LiveRange* result = LiveRangeFor(vreg);
   range->SplitAt(pos, result, zone_);
   return result;
 }
@@ -2075,6 +2080,7 @@
         second_part,
         second_part->Start().InstructionEnd(),
         end.PrevInstruction().InstructionEnd());
+    if (!AllocationOk()) return;
 
     ASSERT(third_part != second_part);
 
diff --git a/src/lithium-allocator.h b/src/lithium-allocator.h
index 2ca8537..0e24d54 100644
--- a/src/lithium-allocator.h
+++ b/src/lithium-allocator.h
@@ -427,8 +427,10 @@
   Zone* zone() const { return zone_; }
 
   int GetVirtualRegister() {
-    if (next_virtual_register_ > LUnallocated::kMaxVirtualRegisters) {
+    if (next_virtual_register_ >= LUnallocated::kMaxVirtualRegisters) {
       allocation_ok_ = false;
+      // Maintain the invariant that we return something below the maximum.
+      return 0;
     }
     return next_virtual_register_++;
   }
diff --git a/src/log.h b/src/log.h
index 27d517a..5c121bc 100644
--- a/src/log.h
+++ b/src/log.h
@@ -139,6 +139,7 @@
   V(REG_EXP_TAG,                    "RegExp")                           \
   V(SCRIPT_TAG,                     "Script")                           \
   V(STORE_IC_TAG,                   "StoreIC")                          \
+  V(STORE_POLYMORPHIC_IC_TAG,       "StorePolymorphicIC")               \
   V(STUB_TAG,                       "Stub")                             \
   V(NATIVE_FUNCTION_TAG,            "Function")                         \
   V(NATIVE_LAZY_COMPILE_TAG,        "LazyCompile")                      \
diff --git a/src/macro-assembler.h b/src/macro-assembler.h
index 9e71123..55dccfa 100644
--- a/src/macro-assembler.h
+++ b/src/macro-assembler.h
@@ -49,7 +49,9 @@
   // words instead of bytes.
   SIZE_IN_WORDS = 1 << 2,
   // Align the allocation to a multiple of kDoubleSize
-  DOUBLE_ALIGNMENT = 1 << 3
+  DOUBLE_ALIGNMENT = 1 << 3,
+  // Directly allocate in old pointer space
+  PRETENURE_OLD_POINTER_SPACE = 1 << 4
 };
 
 
@@ -168,6 +170,26 @@
 
 #endif  // DEBUG
 
+
+class AllocationUtils {
+ public:
+  static ExternalReference GetAllocationTopReference(
+      Isolate* isolate, AllocationFlags flags) {
+    return ((flags & PRETENURE_OLD_POINTER_SPACE) != 0) ?
+        ExternalReference::old_pointer_space_allocation_top_address(isolate) :
+        ExternalReference::new_space_allocation_top_address(isolate);
+  }
+
+
+  static ExternalReference GetAllocationLimitReference(
+      Isolate* isolate, AllocationFlags flags) {
+    return ((flags & PRETENURE_OLD_POINTER_SPACE) != 0) ?
+        ExternalReference::old_pointer_space_allocation_limit_address(isolate) :
+        ExternalReference::new_space_allocation_limit_address(isolate);
+  }
+};
+
+
 } }  // namespace v8::internal
 
 #endif  // V8_MACRO_ASSEMBLER_H_
diff --git a/src/mips/assembler-mips-inl.h b/src/mips/assembler-mips-inl.h
index 1dad815..9c9f611 100644
--- a/src/mips/assembler-mips-inl.h
+++ b/src/mips/assembler-mips-inl.h
@@ -139,14 +139,14 @@
 
 
 Address RelocInfo::target_address() {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
   return Assembler::target_address_at(pc_);
 }
 
 
 Address RelocInfo::target_address_address() {
   ASSERT(IsCodeTarget(rmode_) ||
-         rmode_ == RUNTIME_ENTRY ||
+         IsRuntimeEntry(rmode_) ||
          rmode_ == EMBEDDED_OBJECT ||
          rmode_ == EXTERNAL_REFERENCE);
   // Read the address of the word containing the target_address in an
@@ -174,7 +174,7 @@
 
 
 void RelocInfo::set_target_address(Address target, WriteBarrierMode mode) {
-  ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
+  ASSERT(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_));
   Assembler::set_target_address_at(pc_, target);
   if (mode == UPDATE_WRITE_BARRIER && host() != NULL && IsCodeTarget(rmode_)) {
     Object* target_code = Code::GetCodeFromTargetAddress(target);
@@ -372,7 +372,7 @@
              Isolate::Current()->debug()->has_break_points()) {
     visitor->VisitDebugTarget(this);
 #endif
-  } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+  } else if (RelocInfo::IsRuntimeEntry(mode)) {
     visitor->VisitRuntimeEntry(this);
   }
 }
@@ -399,7 +399,7 @@
               IsPatchedDebugBreakSlotSequence()))) {
     StaticVisitor::VisitDebugTarget(heap, this);
 #endif
-  } else if (mode == RelocInfo::RUNTIME_ENTRY) {
+  } else if (RelocInfo::IsRuntimeEntry(mode)) {
     StaticVisitor::VisitRuntimeEntry(this);
   }
 }
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc
index 1af9d3f..f398a4d 100644
--- a/src/mips/code-stubs-mips.cc
+++ b/src/mips/code-stubs-mips.cc
@@ -4585,7 +4585,7 @@
 
   StubCompiler::GenerateLoadArrayLength(masm, receiver, a3, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4614,7 +4614,7 @@
 
   StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, a3, t0, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4645,7 +4645,7 @@
                                          support_wrapper_);
 
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -4715,7 +4715,7 @@
 
   __ bind(&miss);
 
-  StubCompiler::GenerateStoreMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc
index 3cd89b8..400f26d 100644
--- a/src/mips/lithium-codegen-mips.cc
+++ b/src/mips/lithium-codegen-mips.cc
@@ -1268,12 +1268,12 @@
             __ sll(result, left, shift);
           } else if (IsPowerOf2(constant_abs - 1)) {
             int32_t shift = WhichPowerOf2(constant_abs - 1);
-            __ sll(result, left, shift);
-            __ Addu(result, result, left);
+            __ sll(scratch, left, shift);
+            __ Addu(result, scratch, left);
           } else if (IsPowerOf2(constant_abs + 1)) {
             int32_t shift = WhichPowerOf2(constant_abs + 1);
-            __ sll(result, left, shift);
-            __ Subu(result, result, left);
+            __ sll(scratch, left, shift);
+            __ Subu(result, scratch, left);
           }
 
           // Correct the sign of the result is the constant is negative.
diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc
index b233d51..f04a462 100644
--- a/src/mips/lithium-mips.cc
+++ b/src/mips/lithium-mips.cc
@@ -668,8 +668,12 @@
 LUnallocated* LChunkBuilder::TempRegister() {
   LUnallocated* operand =
       new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
-  operand->set_virtual_register(allocator_->GetVirtualRegister());
-  if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+  int vreg = allocator_->GetVirtualRegister();
+  if (!allocator_->AllocationOk()) {
+    Abort("Out of virtual registers while trying to allocate temp register.");
+    return NULL;
+  }
+  operand->set_virtual_register(vreg);
   return operand;
 }
 
@@ -928,7 +932,7 @@
 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
   HValue* value = instr->value();
   if (value->EmitAtUses()) {
-    HBasicBlock* successor = HConstant::cast(value)->ToBoolean()
+    HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
         ? instr->FirstSuccessor()
         : instr->SecondSuccessor();
     return new(zone()) LGoto(successor->block_id());
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc
index 242fa1e..af436b6 100644
--- a/src/mips/macro-assembler-mips.cc
+++ b/src/mips/macro-assembler-mips.cc
@@ -3960,7 +3960,8 @@
 
 
 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
+  ASSERT(allow_stub_calls_ ||
+         stub->CompilingCallsToThisStubIsGCSafe(isolate()));
   Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET);
 }
 
@@ -4078,7 +4079,7 @@
 
 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate());
 }
 
 
@@ -4914,8 +4915,8 @@
     push(object);
     lw(object, FieldMemOperand(object, HeapObject::kMapOffset));
     lbu(object, FieldMemOperand(object, Map::kInstanceTypeOffset));
-    pop(object);
     Check(le, "Operand is not a name", object, Operand(LAST_NAME_TYPE));
+    pop(object);
   }
 }
 
diff --git a/src/mips/regexp-macro-assembler-mips.cc b/src/mips/regexp-macro-assembler-mips.cc
index ce2d635..036cbb1 100644
--- a/src/mips/regexp-macro-assembler-mips.cc
+++ b/src/mips/regexp-macro-assembler-mips.cc
@@ -341,9 +341,6 @@
     __ Or(t0, t0, Operand(0x20));  // Also convert input character.
     __ Branch(&fail, ne, t0, Operand(a3));
     __ Subu(a3, a3, Operand('a'));
-#ifndef ENABLE_LATIN_1
-    __ Branch(&fail, hi, a3, Operand('z' - 'a'));  // Is a3 a lowercase letter?
-#else
     __ Branch(&loop_check, ls, a3, Operand('z' - 'a'));
     // Latin-1: Check for values in range [224,254] but not 247.
     __ Subu(a3, a3, Operand(224 - 'a'));
@@ -351,7 +348,6 @@
     __ Branch(&fail, hi, a3, Operand(254 - 224));
     // Check for 247.
     __ Branch(&fail, eq, a3, Operand(247 - 224));
-#endif
 
     __ bind(&loop_check);
     __ Branch(&loop, lt, a0, Operand(a1));
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index 4d58c75..959da8e 100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -307,19 +307,6 @@
 }
 
 
-// Load a fast property out of a holder object (src). In-object properties
-// are loaded directly otherwise the property is loaded from the properties
-// fixed array.
-void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
-                                            Register dst,
-                                            Register src,
-                                            Handle<JSObject> holder,
-                                            PropertyIndex index) {
-  DoGenerateFastPropertyLoad(
-      masm, dst, src, index.is_inobject(holder), index.translate(holder));
-}
-
-
 void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm,
                                               Register dst,
                                               Register src,
@@ -433,9 +420,11 @@
                                       Handle<Name> name,
                                       Register receiver_reg,
                                       Register name_reg,
+                                      Register value_reg,
                                       Register scratch1,
                                       Register scratch2,
-                                      Label* miss_label) {
+                                      Label* miss_label,
+                                      Label* miss_restore_name) {
   // a0 : value.
   Label exit;
 
@@ -472,17 +461,8 @@
         holder = JSObject::cast(holder->GetPrototype());
       } while (holder->GetPrototype()->IsJSObject());
     }
-    // We need an extra register, push
-    __ push(name_reg);
-    Label miss_pop, done_check;
     CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
-                    scratch1, scratch2, name, &miss_pop);
-    __ jmp(&done_check);
-    __ bind(&miss_pop);
-    __ pop(name_reg);
-    __ jmp(miss_label);
-    __ bind(&done_check);
-    __ pop(name_reg);
+                    scratch1, scratch2, name, miss_restore_name);
   }
 
   // Stub never generated for non-global objects that require access
@@ -528,14 +508,14 @@
   if (index < 0) {
     // Set the property straight into the object.
     int offset = object->map()->instance_size() + (index * kPointerSize);
-    __ sw(a0, FieldMemOperand(receiver_reg, offset));
+    __ sw(value_reg, FieldMemOperand(receiver_reg, offset));
 
     // Skip updating write barrier if storing a smi.
-    __ JumpIfSmi(a0, &exit, scratch1);
+    __ JumpIfSmi(value_reg, &exit);
 
     // Update the write barrier for the array address.
     // Pass the now unused name_reg as a scratch register.
-    __ mov(name_reg, a0);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(receiver_reg,
                         offset,
                         name_reg,
@@ -548,14 +528,14 @@
     // Get the properties array.
     __ lw(scratch1,
           FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset));
-    __ sw(a0, FieldMemOperand(scratch1, offset));
+    __ sw(value_reg, FieldMemOperand(scratch1, offset));
 
     // Skip updating write barrier if storing a smi.
-    __ JumpIfSmi(a0, &exit);
+    __ JumpIfSmi(value_reg, &exit);
 
     // Update the write barrier for the array address.
     // Ok to clobber receiver_reg and name_reg, since we return.
-    __ mov(name_reg, a0);
+    __ mov(name_reg, value_reg);
     __ RecordWriteField(scratch1,
                         offset,
                         name_reg,
@@ -565,27 +545,20 @@
   }
 
   // Return the value (register v0).
+  ASSERT(value_reg.is(a0));
   __ bind(&exit);
   __ mov(v0, a0);
   __ Ret();
 }
 
 
-void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
-  Handle<Code> code = (kind == Code::LOAD_IC)
-      ? masm->isolate()->builtins()->LoadIC_Miss()
-      : masm->isolate()->builtins()->KeyedLoadIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
-  Handle<Code> code = (kind == Code::STORE_IC)
-      ? masm->isolate()->builtins()->StoreIC_Miss()
-      : masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
+void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
+                                                Label* label,
+                                                Handle<Name> name) {
+  if (!label->is_unused()) {
+    __ bind(label);
+    __ li(this->name(), Operand(name));
+  }
 }
 
 
@@ -1064,15 +1037,15 @@
 }
 
 
-#undef __
-#define __ ACCESS_MASM(masm())
-
-
-void StubCompiler::GenerateTailCall(Handle<Code> code) {
+void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
   __ Jump(code, RelocInfo::CODE_TARGET);
 }
 
 
+#undef __
+#define __ ACCESS_MASM(masm())
+
+
 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
                                        Register object_reg,
                                        Handle<JSObject> holder,
@@ -1190,7 +1163,7 @@
   if (!miss->is_unused()) {
     __ Branch(success);
     __ bind(miss);
-    GenerateLoadMiss(masm(), kind());
+    TailCallBuiltin(masm(), MissBuiltin(kind()));
   }
 }
 
@@ -2629,38 +2602,6 @@
 }
 
 
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                  int index,
-                                                  Handle<Map> transition,
-                                                  Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- a0    : value
-  //  -- a1    : receiver
-  //  -- a2    : name
-  //  -- ra    : return address
-  // -----------------------------------
-  Label miss;
-
-  // Name register might be clobbered.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     a1, a2, a3, t0,
-                     &miss);
-  __ bind(&miss);
-  __ li(a2, Operand(Handle<Name>(name)));  // Restore name.
-  Handle<Code> ic = masm()->isolate()->builtins()->Builtins::StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreCallback(
     Handle<Name> name,
     Handle<JSObject> receiver,
@@ -2693,11 +2634,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
+  return GetICCode(kind(), Code::CALLBACKS, name);
 }
 
 
@@ -2767,11 +2707,10 @@
   GenerateStoreViaSetter(masm(), setter);
 
   __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
+  return GetICCode(kind(), Code::CALLBACKS, name);
 }
 
 
@@ -2801,7 +2740,7 @@
 
   __ Push(a1, a2, a0);  // Receiver, name, value.
 
-  __ li(a0, Operand(Smi::FromInt(strict_mode_)));
+  __ li(a0, Operand(Smi::FromInt(strict_mode())));
   __ push(a0);  // Strict mode.
 
   // Do tail-call to the runtime system.
@@ -2812,11 +2751,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = masm()->isolate()->builtins()->Builtins::StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::INTERCEPTOR, name);
+  return GetICCode(kind(), Code::INTERCEPTOR, name);
 }
 
 
@@ -2857,11 +2795,10 @@
   // Handle store cache miss.
   __ bind(&miss);
   __ IncrementCounter(counters->named_store_global_inline_miss(), 1, a1, a3);
-  Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, name);
+  return GetICCode(kind(), Code::NORMAL, name);
 }
 
 
@@ -2898,6 +2835,20 @@
 }
 
 
+Register* StoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { a1, a2, a0, a3, t0, t1 };
+  return registers;
+}
+
+
+Register* KeyedStoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { a2, a1, a0, a3, t0, t1 };
+  return registers;
+}
+
+
 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
                                               Register name_reg,
                                               Label* miss) {
@@ -2905,6 +2856,13 @@
 }
 
 
+void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name,
+                                               Register name_reg,
+                                               Label* miss) {
+  __ Branch(miss, ne, name_reg, Operand(name));
+}
+
+
 #undef __
 #define __ ACCESS_MASM(masm)
 
@@ -2998,8 +2956,7 @@
     __ DispatchMap(a1, a2, receiver_map, stub, DO_SMI_CHECK);
   }
 
-  Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
@@ -3029,7 +2986,7 @@
   }
 
   __ bind(&miss);
-  GenerateLoadMiss(masm(), kind());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   InlineCacheState state =
@@ -3038,47 +2995,6 @@
 }
 
 
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                       int index,
-                                                       Handle<Map> transition,
-                                                       Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- a0    : value
-  //  -- a1    : key
-  //  -- a2    : receiver
-  //  -- ra    : return address
-  // -----------------------------------
-
-  Label miss;
-
-  Counters* counters = masm()->isolate()->counters();
-  __ IncrementCounter(counters->keyed_store_field(), 1, a3, t0);
-
-  // Check that the name has not changed.
-  __ Branch(&miss, ne, a1, Operand(name));
-
-  // a3 is used as scratch register. a1 and a2 keep their values if a jump to
-  // the miss label is generated.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     a2, a1, a3, t0,
-                     &miss);
-  __ bind(&miss);
-
-  __ DecrementCounter(counters->keyed_store_field(), 1, a3, t0);
-  Handle<Code> ic = masm()->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
 Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
     Handle<Map> receiver_map) {
   // ----------- S t a t e -------------
@@ -3097,11 +3013,10 @@
 
   __ DispatchMap(a2, a3, receiver_map, stub, DO_SMI_CHECK);
 
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string());
+  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
 }
 
 
@@ -3135,11 +3050,11 @@
   }
 
   __ bind(&miss);
-  Handle<Code> miss_ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
+  return GetICCode(
+      kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
 }
 
 
@@ -3327,9 +3242,7 @@
   //  -- a0     : key
   //  -- a1     : receiver
   // -----------------------------------
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_Slow();
-  __ Jump(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow);
 
   // Miss case, call the runtime.
   __ bind(&miss_force_generic);
@@ -3339,10 +3252,7 @@
   //  -- a0     : key
   //  -- a1     : receiver
   // -----------------------------------
-
-  Handle<Code> miss_ic =
-     masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
 }
 
 
@@ -3796,9 +3706,7 @@
   //  -- a0     : key
   //  -- a1     : receiver
   // -----------------------------------
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedStoreIC_Slow();
-  __ Jump(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
 
   // Miss case, call the runtime.
   __ bind(&miss_force_generic);
@@ -3808,10 +3716,7 @@
   //  -- a0     : key
   //  -- a1     : receiver
   // -----------------------------------
-
-  Handle<Code> miss_ic =
-     masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 }
 
 
@@ -3902,13 +3807,10 @@
   __ Ret();
 
   __ bind(&miss_force_generic);
-  Handle<Code> ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -3972,8 +3874,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ Jump(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
@@ -4049,13 +3950,10 @@
 
   // Handle store cache miss, replacing the ic with the generic stub.
   __ bind(&miss_force_generic);
-  Handle<Code> ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -4138,8 +4036,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ Jump(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index a3665e9..abfe693 100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -318,11 +318,12 @@
             "\nException thrown while compiling natives - see above.\n\n");
     exit(1);
   }
+  Isolate* isolate = context->GetIsolate();
   if (i::FLAG_extra_code != NULL) {
     context->Enter();
     // Capture 100 frames if anything happens.
     V8::SetCaptureStackTraceForUncaughtExceptions(true, 100);
-    HandleScope scope;
+    HandleScope scope(isolate);
     const char* name = i::FLAG_extra_code;
     FILE* file = i::OS::FOpen(name, "rb");
     if (file == NULL) {
@@ -375,7 +376,7 @@
     context->Exit();
   }
   // Make sure all builtin scripts are cached.
-  { HandleScope scope;
+  { HandleScope scope(isolate);
     for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
       i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
     }
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index 3cb3d24..82a71a5 100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -486,19 +486,10 @@
     ConsString::cast(this)->ConsStringVerify();
   } else if (IsSlicedString()) {
     SlicedString::cast(this)->SlicedStringVerify();
-  } else if (IsSeqOneByteString()) {
-    SeqOneByteString::cast(this)->SeqOneByteStringVerify();
   }
 }
 
 
-void SeqOneByteString::SeqOneByteStringVerify() {
-#ifndef ENABLE_LATIN_1
-  CHECK(String::IsAscii(GetChars(), length()));
-#endif
-}
-
-
 void ConsString::ConsStringVerify() {
   CHECK(this->first()->IsString());
   CHECK(this->second() == GetHeap()->empty_string() ||
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 7ddfdfc..9a520b2 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -357,12 +357,7 @@
 
 bool String::HasOnlyAsciiChars() {
   uint32_t type = map()->instance_type();
-#ifndef ENABLE_LATIN_1
-  return (type & kStringEncodingMask) == kOneByteStringTag ||
-         (type & kAsciiDataHintMask) == kAsciiDataHintTag;
-#else
   return (type & kAsciiDataHintMask) == kAsciiDataHintTag;
-#endif
 }
 
 
diff --git a/src/objects.cc b/src/objects.cc
index a57e264..3de981c 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -768,8 +768,6 @@
         // that even though we may not actually end up loading the named
         // property from the current object, we still check that we have
         // access to it.
-        // TODO(dcarney): revert.
-        CHECK(current->IsJSObject());
         JSObject* checked = JSObject::cast(current);
         if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
           return checked->GetPropertyWithFailedAccessCheck(receiver,
@@ -9110,7 +9108,7 @@
     } else if (last_comment != NULL &&
                bailout_id == Deoptimizer::GetDeoptimizationId(
                    info->target_address(), Deoptimizer::EAGER)) {
-      CHECK(info->rmode() == RelocInfo::RUNTIME_ENTRY);
+      CHECK(RelocInfo::IsRuntimeEntry(info->rmode()));
       PrintF("            %s\n", last_comment);
       return;
     }
diff --git a/src/objects.h b/src/objects.h
index 9d52554..89ebf21 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7796,8 +7796,6 @@
   // Q.v. String::kMaxLength which is the maximal size of concatenated strings.
   static const int kMaxLength = (kMaxSize - kHeaderSize);
 
-  DECLARE_VERIFIER(SeqOneByteString)
-
  private:
   DISALLOW_IMPLICIT_CONSTRUCTORS(SeqOneByteString);
 };
diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc
index abcce7b..b982b94 100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -76,29 +76,20 @@
 
 
 void OptimizingCompilerThread::CompileNext() {
-  Heap::RelocationLock relocation_lock(isolate_->heap());
   OptimizingCompiler* optimizing_compiler = NULL;
   input_queue_.Dequeue(&optimizing_compiler);
   Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(-1));
 
-  ASSERT(optimizing_compiler->info()->closure()->IsInRecompileQueue());
-
+  // The function may have already been optimized by OSR.  Simply continue.
   OptimizingCompiler::Status status = optimizing_compiler->OptimizeGraph();
+  USE(status);   // Prevent an unused-variable error in release mode.
   ASSERT(status != OptimizingCompiler::FAILED);
-  // Prevent an unused-variable error in release mode.
-  USE(status);
 
-  output_queue_.Enqueue(optimizing_compiler);
-
-  // The execution thread can call InstallOptimizedFunctions() at any time,
-  // including at this point, after queuing for install and before marking
-  // for install.  To avoid race condition, functions that are queued but not
-  // yet marked for install are not processed by InstallOptimizedFunctions().
-
-  ASSERT(optimizing_compiler->info()->closure()->IsInRecompileQueue());
-  // Mark function to generate and install optimized code.  We assume this
-  // write to be atomic.
+  // The function may have already been optimized by OSR.  Simply continue.
+  // Mark it for installing before queuing so that we can be sure of the write
+  // order: marking first and (after being queued) installing code second.
   optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
+  output_queue_.Enqueue(optimizing_compiler);
 }
 
 
@@ -109,10 +100,6 @@
   stop_semaphore_->Wait();
 
   if (FLAG_parallel_recompilation_delay != 0) {
-    // Execution ended before we managed to compile and install the remaining
-    // functions in the queue.  We still want to do that for debugging though.
-    // At this point the optimizing thread already stopped, so we finish
-    // processing the queue in the main thread.
     InstallOptimizedFunctions();
     // Barrier when loading queue length is not necessary since the write
     // happens in CompileNext on the same thread.
@@ -136,23 +123,9 @@
   HandleScope handle_scope(isolate_);
   int functions_installed = 0;
   while (!output_queue_.IsEmpty()) {
-    OptimizingCompiler* compiler = *output_queue_.Peek();
-
-    if (compiler->info()->closure()->IsInRecompileQueue()) {
-      // A function may be queued for install, but not marked as such yet.
-      // We continue with the output queue the next to avoid race condition.
-      break;
-    }
+    OptimizingCompiler* compiler;
     output_queue_.Dequeue(&compiler);
-
-#ifdef DEBUG
-    // Create new closure handle since the deferred handle is about to die.
-    Handle<JSFunction> closure(*compiler->info()->closure());
-#endif  // DEBUG
-
     Compiler::InstallOptimizedCode(compiler);
-    // Assert that the marker builtin has been replaced by actual code.
-    ASSERT(!closure->IsInRecompileQueue());
     functions_installed++;
   }
 }
@@ -163,6 +136,7 @@
   ASSERT(IsQueueAvailable());
   ASSERT(!IsOptimizerThread());
   Barrier_AtomicIncrement(&queue_length_, static_cast<Atomic32>(1));
+  optimizing_compiler->info()->closure()->MarkInRecompileQueue();
   input_queue_.Enqueue(optimizing_compiler);
   input_queue_semaphore_->Signal();
 }
diff --git a/src/optimizing-compiler-thread.h b/src/optimizing-compiler-thread.h
index 40599ff..8cb5e2d 100644
--- a/src/optimizing-compiler-thread.h
+++ b/src/optimizing-compiler-thread.h
@@ -93,7 +93,6 @@
   Isolate* isolate_;
   Semaphore* stop_semaphore_;
   Semaphore* input_queue_semaphore_;
-  Semaphore* output_queue_semaphore_;
   UnboundQueue<OptimizingCompiler*> input_queue_;
   UnboundQueue<OptimizingCompiler*> output_queue_;
   volatile AtomicWord stop_thread_;
diff --git a/src/runtime.cc b/src/runtime.cc
index f68672d..12777e7 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5675,9 +5675,7 @@
 namespace {
 
 static const uintptr_t kOneInEveryByte = kUintptrAllBitsSet / 0xFF;
-#ifdef ENABLE_LATIN_1
 static const uintptr_t kAsciiMask = kOneInEveryByte << 7;
-#endif
 
 // Given a word and two range boundaries returns a word with high bit
 // set in every byte iff the corresponding input byte was strictly in
@@ -5690,11 +5688,6 @@
   // Use strict inequalities since in edge cases the function could be
   // further simplified.
   ASSERT(0 < m && m < n);
-#ifndef ENABLE_LATIN_1
-  // Every byte in an ASCII string is less than or equal to 0x7F.
-  ASSERT((w & (kOneInEveryByte * 0x7F)) == w);
-  ASSERT(n < 0x7F);
-#endif
   // Has high bit set in every w byte less than n.
   uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
   // Has high bit set in every w byte greater than m.
@@ -5711,11 +5704,7 @@
 
 template <AsciiCaseConversion dir>
 struct FastAsciiConverter {
-#ifdef ENABLE_LATIN_1
   static bool Convert(char* dst, char* src, int length, bool* changed_out) {
-#else
-  static bool Convert(char* dst, char* src, int length) {
-#endif
 #ifdef DEBUG
     char* saved_dst = dst;
     char* saved_src = src;
@@ -5727,18 +5716,14 @@
     const char lo = (dir == ASCII_TO_LOWER) ? 'A' - 1 : 'a' - 1;
     const char hi = (dir == ASCII_TO_LOWER) ? 'Z' + 1 : 'z' + 1;
     bool changed = false;
-#ifdef ENABLE_LATIN_1
     uintptr_t or_acc = 0;
-#endif
     char* const limit = src + length;
 #ifdef V8_HOST_CAN_READ_UNALIGNED
     // Process the prefix of the input that requires no conversion one
     // (machine) word at a time.
     while (src <= limit - sizeof(uintptr_t)) {
       uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
-#ifdef ENABLE_LATIN_1
       or_acc |= w;
-#endif
       if (AsciiRangeMask(w, lo, hi) != 0) {
         changed = true;
         break;
@@ -5751,9 +5736,7 @@
     // required one word at a time.
     while (src <= limit - sizeof(uintptr_t)) {
       uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
-#ifdef ENABLE_LATIN_1
       or_acc |= w;
-#endif
       uintptr_t m = AsciiRangeMask(w, lo, hi);
       // The mask has high (7th) bit set in every byte that needs
       // conversion and we know that the distance between cases is
@@ -5767,9 +5750,7 @@
     // unaligned access is not supported).
     while (src < limit) {
       char c = *src;
-#ifdef ENABLE_LATIN_1
       or_acc |= c;
-#endif
       if (lo < c && c < hi) {
         c ^= (1 << 5);
         changed = true;
@@ -5778,20 +5759,14 @@
       ++src;
       ++dst;
     }
-#ifdef ENABLE_LATIN_1
     if ((or_acc & kAsciiMask) != 0) {
       return false;
     }
-#endif
 #ifdef DEBUG
     CheckConvert(saved_dst, saved_src, length, changed);
 #endif
-#ifdef ENABLE_LATIN_1
     *changed_out = changed;
     return true;
-#else
-    return changed;
-#endif
   }
 
 #ifdef DEBUG
@@ -5856,13 +5831,6 @@
       if (!maybe_o->ToObject(&o)) return maybe_o;
     }
     SeqOneByteString* result = SeqOneByteString::cast(o);
-#ifndef ENABLE_LATIN_1
-    bool has_changed_character = ConvertTraits::AsciiConverter::Convert(
-        reinterpret_cast<char*>(result->GetChars()),
-        reinterpret_cast<char*>(SeqOneByteString::cast(s)->GetChars()),
-        length);
-    return has_changed_character ? result : s;
-#else
     bool has_changed_character;
     bool is_ascii = ConvertTraits::AsciiConverter::Convert(
         reinterpret_cast<char*>(result->GetChars()),
@@ -5873,7 +5841,6 @@
     if (is_ascii) {
       return has_changed_character ? result : s;
     }
-#endif
   }
 
   Object* answer;
@@ -7762,7 +7729,7 @@
   CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
   if (!AllowOptimization(isolate, function)) {
     function->ReplaceCode(function->shared()->code());
-    return function->code();
+    return isolate->heap()->undefined_value();
   }
   function->shared()->code()->set_profiler_ticks(0);
   ASSERT(FLAG_parallel_recompilation);
@@ -7775,10 +7742,13 @@
   HandleScope handle_scope(isolate);
   ASSERT(args.length() == 1);
   CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
-  if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value();
-  ASSERT(FLAG_parallel_recompilation);
+  ASSERT(V8::UseCrankshaft() && FLAG_parallel_recompilation);
   OptimizingCompilerThread* opt_thread = isolate->optimizing_compiler_thread();
-  opt_thread->InstallOptimizedFunctions();
+  do {
+    // The function could have been marked for installing, but not queued just
+    // yet.  In this case, retry until installed.
+    opt_thread->InstallOptimizedFunctions();
+  } while (function->IsMarkedForInstallingRecompiledCode());
   return function->code();
 }
 
@@ -9127,6 +9097,27 @@
 }
 
 
+RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInOldPointerSpace) {
+  // Allocate a block of memory in old pointer space (filled with a filler).
+  // Use as fallback for allocation in generated code when old pointer space
+  // is full.
+  ASSERT(args.length() == 1);
+  CONVERT_ARG_HANDLE_CHECKED(Smi, size_smi, 0);
+  int size = size_smi->value();
+  RUNTIME_ASSERT(IsAligned(size, kPointerSize));
+  RUNTIME_ASSERT(size > 0);
+  Heap* heap = isolate->heap();
+  Object* allocation;
+  { MaybeObject* maybe_allocation =
+        heap->old_pointer_space()->AllocateRaw(size);
+    if (maybe_allocation->ToObject(&allocation)) {
+      heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
+    }
+    return maybe_allocation;
+  }
+}
+
+
 // Push an object unto an array of objects if it is not already in the
 // array.  Returns true if the element was pushed on the stack and
 // false otherwise.
diff --git a/src/runtime.h b/src/runtime.h
index 934de82..2959fed 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -101,6 +101,7 @@
   F(CompileForOnStackReplacement, 1, 1) \
   F(SetNewFunctionAttributes, 1, 1) \
   F(AllocateInNewSpace, 1, 1) \
+  F(AllocateInOldPointerSpace, 1, 1) \
   F(SetNativeFlag, 1, 1) \
   F(StoreArrayLiteralElement, 5, 1) \
   F(DebugCallbackSupportsStepping, 1, 1) \
diff --git a/src/serialize.cc b/src/serialize.cc
index e587dfa..0ba730f 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -544,6 +544,20 @@
       UNCLASSIFIED,
       55,
       "Runtime::AllocateInNewSpace");
+  Add(ExternalReference::old_pointer_space_allocation_top_address(
+      isolate).address(),
+      UNCLASSIFIED,
+      56,
+      "Heap::OldPointerSpaceAllocationTopAddress");
+  Add(ExternalReference::old_pointer_space_allocation_limit_address(
+      isolate).address(),
+      UNCLASSIFIED,
+      57,
+      "Heap::OldPointerSpaceAllocationLimitAddress");
+  Add(ExternalReference(Runtime::kAllocateInOldPointerSpace, isolate).address(),
+      UNCLASSIFIED,
+      58,
+      "Runtime::AllocateInOldPointerSpace");
 
   // Add a small set of deopt entry addresses to encoder without generating the
   // deopt table code, which isn't possible at deserialization time.
@@ -554,7 +568,7 @@
         entry,
         Deoptimizer::LAZY,
         Deoptimizer::CALCULATE_ENTRY_ADDRESS);
-    Add(address, LAZY_DEOPTIMIZATION, 56 + entry, "lazy_deopt");
+    Add(address, LAZY_DEOPTIMIZATION, 59 + entry, "lazy_deopt");
   }
 }
 
diff --git a/src/spaces.cc b/src/spaces.cc
index 701d46f..2952fd5 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -537,6 +537,17 @@
 void MemoryChunk::InsertAfter(MemoryChunk* other) {
   next_chunk_ = other->next_chunk_;
   prev_chunk_ = other;
+
+  // This memory barrier is needed since concurrent sweeper threads may iterate
+  // over the list of pages while a new page is inserted.
+  // TODO(hpayer): find a cleaner way to guarantee that the page list can be
+  // expanded concurrently
+  MemoryBarrier();
+
+  // The following two write operations can take effect in arbitrary order
+  // since pages are always iterated by the sweeper threads in LIFO order, i.e,
+  // the inserted page becomes visible for the sweeper threads after
+  // other->next_chunk_ = this;
   other->next_chunk_->prev_chunk_ = this;
   other->next_chunk_ = this;
 }
diff --git a/src/spaces.h b/src/spaces.h
index 6847b31..39c19a4 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1663,6 +1663,10 @@
   Address top() { return allocation_info_.top; }
   Address limit() { return allocation_info_.limit; }
 
+  // The allocation top and limit addresses.
+  Address* allocation_top_address() { return &allocation_info_.top; }
+  Address* allocation_limit_address() { return &allocation_info_.limit; }
+
   // Allocate the requested number of bytes in the space if possible, return a
   // failure object if not.
   MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes);
diff --git a/src/string-search.h b/src/string-search.h
index 86237f3..bc685ff 100644
--- a/src/string-search.h
+++ b/src/string-search.h
@@ -53,11 +53,7 @@
   // a potentially less efficient searching, but is a safe approximation.
   // For needles using only characters in the same Unicode 256-code point page,
   // there is no search speed degradation.
-#ifndef ENABLE_LATIN_1
-  static const int kAsciiAlphabetSize = 128;
-#else
   static const int kAsciiAlphabetSize = 256;
-#endif
   static const int kUC16AlphabetSize = Isolate::kUC16AlphabetSize;
 
   // Bad-char shift table stored in the state. It's length is the alphabet size.
@@ -155,11 +151,7 @@
   void PopulateBoyerMooreTable();
 
   static inline bool exceedsOneByte(uint8_t c) {
-#ifdef ENABLE_LATIN_1
     return false;
-#else
-    return c > String::kMaxOneByteCharCodeU;
-#endif
   }
 
   static inline bool exceedsOneByte(uint16_t c) {
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index ac94fff..3dba2d6 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -112,9 +112,9 @@
 Handle<Code> StubCache::FindIC(Handle<Name> name,
                                Handle<JSObject> stub_holder,
                                Code::Kind kind,
-                               Code::StubType type) {
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      kind, Code::kNoExtraICState, type);
+                               Code::StubType type,
+                               Code::ExtraICState extra_ic_state) {
+  Code::Flags flags = Code::ComputeMonomorphicFlags(kind, extra_ic_state, type);
   Handle<Object> probe(stub_holder->map()->FindInCodeCache(*name, flags),
                        isolate_);
   if (probe->IsCode()) return Handle<Code>::cast(probe);
@@ -122,18 +122,14 @@
 }
 
 
-Handle<Code> StubCache::FindStub(Handle<Name> name,
-                                 Handle<JSObject> stub_holder,
-                                 Code::Kind kind,
-                                 Code::StubType type) {
+Handle<Code> StubCache::FindHandler(Handle<Name> name,
+                                    Handle<JSObject> stub_holder,
+                                    Code::Kind kind,
+                                    Code::StubType type,
+                                    Code::ExtraICState extra_ic_state) {
   ASSERT(type != Code::NORMAL);
-  int extra_flags = -1;
-  if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) {
-    extra_flags = kind;
-    kind = Code::STUB;
-  }
   Code::Flags flags = Code::ComputeMonomorphicFlags(
-      kind, Code::kNoExtraICState, type, extra_flags);
+      Code::STUB, extra_ic_state, type, kind);
   Handle<Object> probe(stub_holder->map()->FindInCodeCache(*name, flags),
                        isolate_);
   if (probe->IsCode()) return Handle<Code>::cast(probe);
@@ -197,7 +193,7 @@
 
   // Compile the stub that is either shared for all names or
   // name specific if there are global objects involved.
-  Handle<Code> handler = FindStub(
+  Handle<Code> handler = FindHandler(
       cache_name, receiver, Code::LOAD_IC, Code::NONEXISTENT);
   if (!handler.is_null()) return handler;
 
@@ -221,7 +217,7 @@
   }
 
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::LOAD_IC, Code::FIELD);
   if (!stub.is_null()) return stub;
 
@@ -240,7 +236,7 @@
     Handle<ExecutableAccessorInfo> callback) {
   ASSERT(v8::ToCData<Address>(callback->getter()) != 0);
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::LOAD_IC, Code::CALLBACKS);
   if (!stub.is_null()) return stub;
 
@@ -257,7 +253,7 @@
                                              Handle<JSObject> holder,
                                              Handle<JSFunction> getter) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::LOAD_IC, Code::CALLBACKS);
   if (!stub.is_null()) return stub;
 
@@ -274,7 +270,7 @@
                                             Handle<JSObject> holder,
                                             Handle<JSFunction> value) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> handler = FindStub(
+  Handle<Code> handler = FindHandler(
       name, stub_holder, Code::LOAD_IC, Code::CONSTANT_FUNCTION);
   if (!handler.is_null()) return handler;
 
@@ -290,7 +286,7 @@
                                                Handle<JSObject> receiver,
                                                Handle<JSObject> holder) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::LOAD_IC, Code::INTERCEPTOR);
   if (!stub.is_null()) return stub;
 
@@ -337,7 +333,7 @@
   }
 
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::KEYED_LOAD_IC, Code::FIELD);
   if (!stub.is_null()) return stub;
 
@@ -354,7 +350,7 @@
                                                  Handle<JSObject> holder,
                                                  Handle<JSFunction> value) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> handler = FindStub(
+  Handle<Code> handler = FindHandler(
       name, stub_holder, Code::KEYED_LOAD_IC, Code::CONSTANT_FUNCTION);
   if (!handler.is_null()) return handler;
 
@@ -369,7 +365,7 @@
                                                     Handle<JSObject> receiver,
                                                     Handle<JSObject> holder) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::KEYED_LOAD_IC, Code::INTERCEPTOR);
   if (!stub.is_null()) return stub;
 
@@ -387,7 +383,7 @@
     Handle<JSObject> holder,
     Handle<ExecutableAccessorInfo> callback) {
   Handle<JSObject> stub_holder = StubHolder(receiver, holder);
-  Handle<Code> stub = FindStub(
+  Handle<Code> stub = FindHandler(
       name, stub_holder, Code::KEYED_LOAD_IC, Code::CALLBACKS);
   if (!stub.is_null()) return stub;
 
@@ -405,12 +401,11 @@
                                           Handle<Map> transition,
                                           StrictModeFlag strict_mode) {
   Code::StubType type =
-      (transition.is_null()) ? Code::FIELD : Code::MAP_TRANSITION;
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode, type);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+      transition.is_null() ? Code::FIELD : Code::MAP_TRANSITION;
+
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::STORE_IC, type, strict_mode);
+  if (!stub.is_null()) return stub;
 
   StoreStubCompiler compiler(isolate_, strict_mode);
   Handle<Code> code =
@@ -473,11 +468,9 @@
                                            Handle<GlobalObject> receiver,
                                            Handle<JSGlobalPropertyCell> cell,
                                            StrictModeFlag strict_mode) {
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::STORE_IC, Code::NORMAL, strict_mode);
+  if (!stub.is_null()) return stub;
 
   StoreStubCompiler compiler(isolate_, strict_mode);
   Handle<Code> code = compiler.CompileStoreGlobal(receiver, cell, name);
@@ -493,11 +486,9 @@
     Handle<ExecutableAccessorInfo> callback,
     StrictModeFlag strict_mode) {
   ASSERT(v8::ToCData<Address>(callback->setter()) != 0);
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode, Code::CALLBACKS);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::STORE_IC, Code::CALLBACKS, strict_mode);
+  if (!stub.is_null()) return stub;
 
   StoreStubCompiler compiler(isolate_, strict_mode);
   Handle<Code> code =
@@ -512,11 +503,9 @@
                                               Handle<JSObject> holder,
                                               Handle<JSFunction> setter,
                                               StrictModeFlag strict_mode) {
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode, Code::CALLBACKS);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::STORE_IC, Code::CALLBACKS, strict_mode);
+  if (!stub.is_null()) return stub;
 
   StoreStubCompiler compiler(isolate_, strict_mode);
   Handle<Code> code =
@@ -529,11 +518,9 @@
 Handle<Code> StubCache::ComputeStoreInterceptor(Handle<Name> name,
                                                 Handle<JSObject> receiver,
                                                 StrictModeFlag strict_mode) {
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode, Code::INTERCEPTOR);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::STORE_IC, Code::INTERCEPTOR, strict_mode);
+  if (!stub.is_null()) return stub;
 
   StoreStubCompiler compiler(isolate_, strict_mode);
   Handle<Code> code = compiler.CompileStoreInterceptor(receiver, name);
@@ -548,11 +535,9 @@
                                                StrictModeFlag strict_mode) {
   Code::StubType type =
       (transition.is_null()) ? Code::FIELD : Code::MAP_TRANSITION;
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::KEYED_STORE_IC, strict_mode, type);
-  Handle<Object> probe(receiver->map()->FindInCodeCache(*name, flags),
-                       isolate_);
-  if (probe->IsCode()) return Handle<Code>::cast(probe);
+  Handle<Code> stub = FindIC(
+      name, receiver, Code::KEYED_STORE_IC, type, strict_mode);
+  if (!stub.is_null()) return stub;
 
   KeyedStoreStubCompiler compiler(isolate(), strict_mode, STANDARD_STORE);
   Handle<Code> code =
@@ -1452,16 +1437,29 @@
   Register reg = HandlerFrontendHeader(object, receiver(), holder, name, &miss);
 
   LoadFieldStub stub(reg, field.is_inobject(holder), field.translate(holder));
-  GenerateTailCall(stub.GetCode(isolate()));
+  GenerateTailCall(masm(), stub.GetCode(isolate()));
 
   __ bind(&miss);
-  GenerateLoadMiss(masm(), kind());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   return GetCode(kind(), Code::FIELD, name);
 }
 
 
+// Load a fast property out of a holder object (src). In-object properties
+// are loaded directly otherwise the property is loaded from the properties
+// fixed array.
+void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
+                                            Register dst,
+                                            Register src,
+                                            Handle<JSObject> holder,
+                                            PropertyIndex index) {
+  DoGenerateFastPropertyLoad(
+      masm, dst, src, index.is_inobject(holder), index.translate(holder));
+}
+
+
 Handle<Code> BaseLoadStubCompiler::CompileLoadConstant(
     Handle<JSObject> object,
     Handle<JSObject> holder,
@@ -1527,7 +1525,7 @@
       LoadFieldStub stub(interceptor_reg,
                          field.is_inobject(holder),
                          field.translate(holder));
-      GenerateTailCall(stub.GetCode(isolate()));
+      GenerateTailCall(masm(), stub.GetCode(isolate()));
     } else {
       // We found FIELD property in prototype chain of interceptor's holder.
       // Retrieve a field from field's holder.
@@ -1581,9 +1579,110 @@
 }
 
 
+Handle<Code> BaseStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
+                                                      int index,
+                                                      Handle<Map> transition,
+                                                      Handle<Name> name) {
+  Label miss, miss_restore_name;
+
+  GenerateNameCheck(name, this->name(), &miss);
+
+  // Generate store field code.
+  GenerateStoreField(masm(),
+                     object,
+                     index,
+                     transition,
+                     name,
+                     receiver(), this->name(), value(), scratch1(), scratch2(),
+                     &miss,
+                     &miss_restore_name);
+
+  // Handle store cache miss.
+  GenerateRestoreName(masm(), &miss_restore_name, name);
+  __ bind(&miss);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
+
+  // Return the generated code.
+  return GetICCode(kind(),
+                   transition.is_null() ? Code::FIELD : Code::MAP_TRANSITION,
+                   name);
+}
+
+
+Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
+    Handle<Name> name,
+    Handle<JSObject> object,
+    Handle<JSObject> holder,
+    Handle<JSFunction> setter) {
+  Label miss, miss_restore_name;
+
+  // Check that the maps haven't changed, preserving the name register.
+  __ JumpIfSmi(receiver(), &miss);
+  CheckPrototypes(object, receiver(), holder,
+                  this->name(), scratch1(), scratch2(),
+                  name, &miss_restore_name);
+
+  GenerateStoreViaSetter(masm(), setter);
+
+  GenerateRestoreName(masm(), &miss_restore_name, name);
+
+  __ bind(&miss);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
+
+  // Return the generated code.
+  return GetICCode(kind(), Code::CALLBACKS, name);
+}
+
+
+Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
+    Handle<Map> receiver_map) {
+  ElementsKind elements_kind = receiver_map->elements_kind();
+  if (receiver_map->has_fast_elements() ||
+      receiver_map->has_external_array_elements()) {
+    Handle<Code> stub = KeyedLoadFastElementStub(
+        receiver_map->instance_type() == JS_ARRAY_TYPE,
+        elements_kind).GetCode(isolate());
+    __ DispatchMap(receiver(), scratch1(), receiver_map, stub, DO_SMI_CHECK);
+  } else {
+    Handle<Code> stub =
+        KeyedLoadDictionaryElementStub().GetCode(isolate());
+    __ DispatchMap(receiver(), scratch1(), receiver_map, stub, DO_SMI_CHECK);
+  }
+
+  TailCallBuiltin(masm(), Builtins::kKeyedLoadIC_Miss);
+
+  // Return the generated code.
+  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
+}
+
+
+Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
+    Handle<Map> receiver_map) {
+  ElementsKind elements_kind = receiver_map->elements_kind();
+  bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
+  Handle<Code> stub =
+      KeyedStoreElementStub(is_jsarray,
+                            elements_kind,
+                            store_mode_).GetCode(isolate());
+
+  __ DispatchMap(receiver(), scratch1(), receiver_map, stub, DO_SMI_CHECK);
+
+  TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss);
+
+  // Return the generated code.
+  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
+}
+
+
 #undef __
 
 
+void StubCompiler::TailCallBuiltin(MacroAssembler* masm, Builtins::Name name) {
+  Handle<Code> code(masm->isolate()->builtins()->builtin(name));
+  GenerateTailCall(masm, code);
+}
+
+
 void LoadStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
   GDBJIT(AddCode(GDBJITInterface::LOAD_IC, *name, *code));
 }
@@ -1594,6 +1693,16 @@
 }
 
 
+void StoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
+  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
+}
+
+
+void KeyedStoreStubCompiler::JitEvent(Handle<Name> name, Handle<Code> code) {
+  GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
+}
+
+
 Handle<Code> BaseLoadStubCompiler::GetICCode(Code::Kind kind,
                                              Code::StubType type,
                                              Handle<Name> name,
@@ -1620,6 +1729,32 @@
 }
 
 
+Handle<Code> BaseStoreStubCompiler::GetICCode(Code::Kind kind,
+                                              Code::StubType type,
+                                              Handle<Name> name,
+                                              InlineCacheState state) {
+  Code::Flags flags = Code::ComputeFlags(
+      kind, state, extra_state(), type);
+  Handle<Code> code = GetCodeWithFlags(flags, name);
+  PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
+  JitEvent(name, code);
+  return code;
+}
+
+
+Handle<Code> BaseStoreStubCompiler::GetCode(Code::Kind kind,
+                                            Code::StubType type,
+                                            Handle<Name> name) {
+  ASSERT(type != Code::NORMAL);
+  Code::Flags flags = Code::ComputeFlags(
+      Code::STUB, MONOMORPHIC, extra_state(), type, kind);
+  Handle<Code> code = GetCodeWithFlags(flags, name);
+  PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
+  JitEvent(name, code);
+  return code;
+}
+
+
 void KeyedLoadStubCompiler::CompileElementHandlers(MapHandleList* receiver_maps,
                                                    CodeHandleList* handlers) {
   for (int i = 0; i < receiver_maps->length(); ++i) {
@@ -1648,31 +1783,6 @@
 }
 
 
-Handle<Code> StoreStubCompiler::GetCode(Code::StubType type,
-                                        Handle<Name> name) {
-  Code::Flags flags = Code::ComputeMonomorphicFlags(
-      Code::STORE_IC, strict_mode_, type);
-  Handle<Code> code = GetCodeWithFlags(flags, name);
-  PROFILE(isolate(), CodeCreateEvent(Logger::STORE_IC_TAG, *code, *name));
-  GDBJIT(AddCode(GDBJITInterface::STORE_IC, *name, *code));
-  return code;
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::GetCode(Code::StubType type,
-                                             Handle<Name> name,
-                                             InlineCacheState state) {
-  Code::ExtraICState extra_state =
-      Code::ComputeExtraICState(store_mode_, strict_mode_);
-  Code::Flags flags =
-      Code::ComputeFlags(Code::KEYED_STORE_IC, state, extra_state, type);
-  Handle<Code> code = GetCodeWithFlags(flags, name);
-  PROFILE(isolate(), CodeCreateEvent(Logger::KEYED_STORE_IC_TAG, *code, *name));
-  GDBJIT(AddCode(GDBJITInterface::KEYED_STORE_IC, *name, *code));
-  return code;
-}
-
-
 Handle<Code> KeyedStoreStubCompiler::CompileStoreElementPolymorphic(
     MapHandleList* receiver_maps) {
   // Collect MONOMORPHIC stubs for all |receiver_maps|.
@@ -1696,7 +1806,7 @@
           elements_kind,
           transitioned_map->elements_kind(),
           is_js_array,
-          strict_mode_,
+          strict_mode(),
           store_mode_).GetCode(isolate());
     } else {
       cached_stub = KeyedStoreElementStub(
diff --git a/src/stub-cache.h b/src/stub-cache.h
index 56e3d4f..7c45566 100644
--- a/src/stub-cache.h
+++ b/src/stub-cache.h
@@ -80,12 +80,15 @@
   Handle<Code> FindIC(Handle<Name> name,
                       Handle<JSObject> stub_holder,
                       Code::Kind kind,
-                      Code::StubType type);
+                      Code::StubType type,
+                      Code::ExtraICState extra_state = Code::kNoExtraICState);
 
-  Handle<Code> FindStub(Handle<Name> name,
-                        Handle<JSObject> stub_holder,
-                        Code::Kind kind,
-                        Code::StubType type);
+  Handle<Code> FindHandler(
+      Handle<Name> name,
+      Handle<JSObject> stub_holder,
+      Code::Kind kind,
+      Code::StubType type,
+      Code::ExtraICState extra_state = Code::kNoExtraICState);
 
   Handle<Code> ComputeMonomorphicIC(Handle<JSObject> receiver,
                                     Handle<Code> handler,
@@ -513,14 +516,23 @@
                           Handle<Name> name,
                           Register receiver_reg,
                           Register name_reg,
+                          Register value_reg,
                           Register scratch1,
                           Register scratch2,
-                          Label* miss_label);
+                          Label* miss_label,
+                          Label* miss_restore_name);
 
-  static void GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind);
-  static void GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind);
-
-  static void GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm);
+  static Builtins::Name MissBuiltin(Code::Kind kind) {
+    switch (kind) {
+      case Code::LOAD_IC: return Builtins::kLoadIC_Miss;
+      case Code::STORE_IC: return Builtins::kStoreIC_Miss;
+      case Code::KEYED_LOAD_IC: return Builtins::kKeyedLoadIC_Miss;
+      case Code::KEYED_STORE_IC: return Builtins::kKeyedStoreIC_Miss;
+      default: UNREACHABLE();
+    }
+    return Builtins::kLoadIC_Miss;
+  }
+  static void TailCallBuiltin(MacroAssembler* masm, Builtins::Name name);
 
   // Generates code that verifies that the property holder has not changed
   // (checking maps of objects in the prototype chain for fast and global
@@ -577,7 +589,7 @@
   Heap* heap() { return isolate()->heap(); }
   Factory* factory() { return isolate()->factory(); }
 
-  void GenerateTailCall(Handle<Code> code);
+  static void GenerateTailCall(MacroAssembler* masm, Handle<Code> code);
 
  private:
   Isolate* isolate_;
@@ -739,8 +751,6 @@
   void CompileElementHandlers(MapHandleList* receiver_maps,
                               CodeHandleList* handlers);
 
-  Handle<Code> CompileLoadElementPolymorphic(MapHandleList* receiver_maps);
-
   static void GenerateLoadDictionaryElement(MacroAssembler* masm);
 
   static Register receiver() { return registers()[0]; }
@@ -760,17 +770,63 @@
 };
 
 
-class StoreStubCompiler: public StubCompiler {
+class BaseStoreStubCompiler: public StubCompiler {
  public:
-  StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode)
-    : StubCompiler(isolate), strict_mode_(strict_mode) { }
+  BaseStoreStubCompiler(Isolate* isolate,
+                        StrictModeFlag strict_mode,
+                        Register* registers)
+      : StubCompiler(isolate),
+        strict_mode_(strict_mode),
+        registers_(registers) { }
 
+  virtual ~BaseStoreStubCompiler() { }
 
   Handle<Code> CompileStoreField(Handle<JSObject> object,
                                  int index,
                                  Handle<Map> transition,
                                  Handle<Name> name);
 
+ protected:
+  Handle<Code> GetICCode(Code::Kind kind,
+                         Code::StubType type,
+                         Handle<Name> name,
+                         InlineCacheState state = MONOMORPHIC);
+
+  Handle<Code> GetCode(Code::Kind kind,
+                       Code::StubType type,
+                       Handle<Name> name);
+
+  void GenerateRestoreName(MacroAssembler* masm,
+                           Label* label,
+                           Handle<Name> name);
+
+  Register receiver() { return registers_[0]; }
+  Register name()     { return registers_[1]; }
+  Register value()    { return registers_[2]; }
+  Register scratch1() { return registers_[3]; }
+  Register scratch2() { return registers_[4]; }
+  Register scratch3() { return registers_[5]; }
+  StrictModeFlag strict_mode() { return strict_mode_; }
+  virtual Code::ExtraICState extra_state() { return strict_mode_; }
+
+ private:
+  virtual Code::Kind kind() = 0;
+  virtual Logger::LogEventsAndTags log_kind(Handle<Code> code) = 0;
+  virtual void JitEvent(Handle<Name> name, Handle<Code> code) = 0;
+  virtual void GenerateNameCheck(Handle<Name> name,
+                                 Register name_reg,
+                                 Label* miss) { }
+  StrictModeFlag strict_mode_;
+  Register* registers_;
+};
+
+
+class StoreStubCompiler: public BaseStoreStubCompiler {
+ public:
+  StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode)
+      : BaseStoreStubCompiler(isolate, strict_mode, registers()) { }
+
+
   Handle<Code> CompileStoreCallback(Handle<Name> name,
                                     Handle<JSObject> object,
                                     Handle<JSObject> holder,
@@ -792,25 +848,24 @@
                                   Handle<Name> name);
 
  private:
-  Handle<Code> GetCode(Code::StubType type, Handle<Name> name);
-
-  StrictModeFlag strict_mode_;
+  static Register* registers();
+  virtual Code::Kind kind() { return Code::STORE_IC; }
+  virtual Logger::LogEventsAndTags log_kind(Handle<Code> code) {
+    if (!code->is_inline_cache_stub()) return Logger::STUB_TAG;
+    return code->ic_state() == MONOMORPHIC
+        ? Logger::STORE_IC_TAG : Logger::STORE_POLYMORPHIC_IC_TAG;
+  }
+  virtual void JitEvent(Handle<Name> name, Handle<Code> code);
 };
 
 
-class KeyedStoreStubCompiler: public StubCompiler {
+class KeyedStoreStubCompiler: public BaseStoreStubCompiler {
  public:
   KeyedStoreStubCompiler(Isolate* isolate,
                          StrictModeFlag strict_mode,
                          KeyedAccessStoreMode store_mode)
-    : StubCompiler(isolate),
-      strict_mode_(strict_mode),
-      store_mode_(store_mode) { }
-
-  Handle<Code> CompileStoreField(Handle<JSObject> object,
-                                 int index,
-                                 Handle<Map> transition,
-                                 Handle<Name> name);
+      : BaseStoreStubCompiler(isolate, strict_mode, registers()),
+        store_mode_(store_mode) { }
 
   Handle<Code> CompileStoreElement(Handle<Map> receiver_map);
 
@@ -834,12 +889,27 @@
 
   static void GenerateStoreDictionaryElement(MacroAssembler* masm);
 
- private:
-  Handle<Code> GetCode(Code::StubType type,
-                       Handle<Name> name,
-                       InlineCacheState state = MONOMORPHIC);
+ protected:
+  virtual Code::ExtraICState extra_state() {
+    return Code::ComputeExtraICState(store_mode_, strict_mode());
+  }
 
-  StrictModeFlag strict_mode_;
+ private:
+  Register transition_map() {
+    return registers()[3];
+  }
+
+  static Register* registers();
+  virtual Code::Kind kind() { return Code::KEYED_STORE_IC; }
+  virtual Logger::LogEventsAndTags log_kind(Handle<Code> code) {
+    if (!code->is_inline_cache_stub()) return Logger::STUB_TAG;
+    return code->ic_state() == MONOMORPHIC
+        ? Logger::KEYED_STORE_IC_TAG : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG;
+  }
+  virtual void JitEvent(Handle<Name> name, Handle<Code> code);
+  virtual void GenerateNameCheck(Handle<Name> name,
+                                 Register name_reg,
+                                 Label* miss);
   KeyedAccessStoreMode store_mode_;
 };
 
diff --git a/src/unicode-inl.h b/src/unicode-inl.h
index c80c67e..02be457 100644
--- a/src/unicode-inl.h
+++ b/src/unicode-inl.h
@@ -95,6 +95,18 @@
 }
 
 
+unsigned Utf8::EncodeOneByte(char* str, uint8_t c) {
+  static const int kMask = ~(1 << 6);
+  if (c <= kMaxOneByteChar) {
+    str[0] = c;
+    return 1;
+  }
+  str[0] = 0xC0 | (c >> 6);
+  str[1] = 0x80 | (c & kMask);
+  return 2;
+}
+
+
 unsigned Utf8::Encode(char* str, uchar c, int previous) {
   static const int kMask = ~(1 << 6);
   if (c <= kMaxOneByteChar) {
diff --git a/src/unicode.h b/src/unicode.h
index f8a1f60..42a8182 100644
--- a/src/unicode.h
+++ b/src/unicode.h
@@ -135,11 +135,7 @@
 
 class Latin1 {
  public:
-#ifndef ENABLE_LATIN_1
-  static const unsigned kMaxChar = 0x7f;
-#else
   static const unsigned kMaxChar = 0xff;
-#endif
   // Returns 0 if character does not convert to single latin-1 character
   // or if the character doesn't not convert back to latin-1 via inverse
   // operation (upper to lower, etc).
@@ -149,6 +145,7 @@
 class Utf8 {
  public:
   static inline uchar Length(uchar chr, int previous);
+  static inline unsigned EncodeOneByte(char* out, uint8_t c);
   static inline unsigned Encode(
       char* out, uchar c, int previous);
   static uchar CalculateValue(const byte* str,
diff --git a/src/v8.cc b/src/v8.cc
index 1753650..2e8cd50 100644
--- a/src/v8.cc
+++ b/src/v8.cc
@@ -268,6 +268,7 @@
     FLAG_gc_global = true;
     FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2;
   }
+  if (FLAG_trace_hydrogen) FLAG_parallel_recompilation = false;
   OS::SetUp();
   CPU::SetUp();
   use_crankshaft_ = FLAG_crankshaft
diff --git a/src/version.cc b/src/version.cc
index b3e5c45..919c8a3 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -34,7 +34,7 @@
 // cannot be changed without changing the SCons build script.
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     17
-#define BUILD_NUMBER      10
+#define BUILD_NUMBER      11
 #define PATCH_LEVEL       0
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
index 7a1e88f..0b70c1a 100644
--- a/src/x64/builtins-x64.cc
+++ b/src/x64/builtins-x64.cc
@@ -1118,12 +1118,7 @@
   if (initial_capacity > 0) {
     size += FixedArray::SizeFor(initial_capacity);
   }
-  __ AllocateInNewSpace(size,
-                        result,
-                        scratch2,
-                        scratch3,
-                        gc_required,
-                        TAG_OBJECT);
+  __ Allocate(size, result, scratch2, scratch3, gc_required, TAG_OBJECT);
 
   // Allocated the JSArray. Now initialize the fields except for the elements
   // array.
@@ -1646,12 +1641,12 @@
 
   // Allocate a JSValue and put the tagged pointer into rax.
   Label gc_required;
-  __ AllocateInNewSpace(JSValue::kSize,
-                        rax,  // Result.
-                        rcx,  // New allocation top (we ignore it).
-                        no_reg,
-                        &gc_required,
-                        TAG_OBJECT);
+  __ Allocate(JSValue::kSize,
+              rax,  // Result.
+              rcx,  // New allocation top (we ignore it).
+              no_reg,
+              &gc_required,
+              TAG_OBJECT);
 
   // Set the map.
   __ LoadGlobalFunctionInitialMap(rdi, rcx);
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 7ebc103..04c3e68 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -140,7 +140,7 @@
   Counters* counters = masm->isolate()->counters();
 
   Label gc;
-  __ AllocateInNewSpace(JSFunction::kSize, rax, rbx, rcx, &gc, TAG_OBJECT);
+  __ Allocate(JSFunction::kSize, rax, rbx, rcx, &gc, TAG_OBJECT);
 
   __ IncrementCounter(counters->fast_new_closure_total(), 1);
 
@@ -274,8 +274,8 @@
   // Try to allocate the context in new space.
   Label gc;
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-  __ AllocateInNewSpace((length * kPointerSize) + FixedArray::kHeaderSize,
-                        rax, rbx, rcx, &gc, TAG_OBJECT);
+  __ Allocate((length * kPointerSize) + FixedArray::kHeaderSize,
+              rax, rbx, rcx, &gc, TAG_OBJECT);
 
   // Get the function from the stack.
   __ movq(rcx, Operand(rsp, 1 * kPointerSize));
@@ -320,8 +320,8 @@
   // Try to allocate the context in new space.
   Label gc;
   int length = slots_ + Context::MIN_CONTEXT_SLOTS;
-  __ AllocateInNewSpace(FixedArray::SizeFor(length),
-                        rax, rbx, rcx, &gc, TAG_OBJECT);
+  __ Allocate(FixedArray::SizeFor(length),
+              rax, rbx, rcx, &gc, TAG_OBJECT);
 
   // Get the function from the stack.
   __ movq(rcx, Operand(rsp, 1 * kPointerSize));
@@ -406,7 +406,7 @@
   if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
     flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
   }
-  __ AllocateInNewSpace(size, rax, rbx, rdx, fail, flags);
+  __ Allocate(size, rax, rbx, rdx, fail, flags);
 
   if (allocation_site_mode == TRACK_ALLOCATION_SITE) {
     __ LoadRoot(kScratchRegister, Heap::kAllocationSiteInfoMapRootIndex);
@@ -1316,12 +1316,8 @@
         // Allocate heap number in new space.
         // Not using AllocateHeapNumber macro in order to reuse
         // already loaded heap_number_map.
-        __ AllocateInNewSpace(HeapNumber::kSize,
-                              rax,
-                              rdx,
-                              no_reg,
-                              &allocation_failed,
-                              TAG_OBJECT);
+        __ Allocate(HeapNumber::kSize, rax, rdx, no_reg, &allocation_failed,
+                    TAG_OBJECT);
         // Set the map.
         __ AssertRootValue(heap_number_map,
                            Heap::kHeapNumberMapRootIndex,
@@ -2403,7 +2399,7 @@
 
   StubCompiler::GenerateLoadArrayLength(masm, receiver, r8, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -2431,7 +2427,7 @@
 
   StubCompiler::GenerateLoadFunctionPrototype(masm, receiver, r8, r9, &miss);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -2460,7 +2456,7 @@
   StubCompiler::GenerateLoadStringLength(masm, receiver, r8, r9, &miss,
                                          support_wrapper_);
   __ bind(&miss);
-  StubCompiler::GenerateLoadMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -2523,7 +2519,7 @@
 
   __ bind(&miss);
 
-  StubCompiler::GenerateStoreMiss(masm, kind());
+  StubCompiler::TailCallBuiltin(masm, StubCompiler::MissBuiltin(kind()));
 }
 
 
@@ -5756,32 +5752,22 @@
   // Compare lengths (precomputed).
   __ bind(&compare_lengths);
   __ SmiTest(length_difference);
-#ifndef ENABLE_LATIN_1
-  __ j(not_zero, &result_not_equal, Label::kNear);
-#else
   Label length_not_equal;
   __ j(not_zero, &length_not_equal, Label::kNear);
-#endif
 
   // Result is EQUAL.
   __ Move(rax, Smi::FromInt(EQUAL));
   __ ret(0);
 
   Label result_greater;
-#ifdef ENABLE_LATIN_1
   Label result_less;
   __ bind(&length_not_equal);
   __ j(greater, &result_greater, Label::kNear);
   __ jmp(&result_less, Label::kNear);
-#endif
   __ bind(&result_not_equal);
   // Unequal comparison of left to right, either character or length.
-#ifndef ENABLE_LATIN_1
-  __ j(greater, &result_greater, Label::kNear);
-#else
   __ j(above, &result_greater, Label::kNear);
   __ bind(&result_less);
-#endif
 
   // Result is LESS.
   __ Move(rax, Smi::FromInt(LESS));
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index ee510eb..8ff12df 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -1514,7 +1514,7 @@
   __ bind(&materialized);
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc
index b185684..0a9ceaa 100644
--- a/src/x64/ic-x64.cc
+++ b/src/x64/ic-x64.cc
@@ -1333,8 +1333,7 @@
   Isolate::Current()->stub_cache()->GenerateProbe(
       masm, flags, rax, rcx, rbx, rdx);
 
-  // Cache miss: Jump to runtime.
-  StubCompiler::GenerateLoadMiss(masm, Code::LOAD_IC);
+  GenerateMiss(masm);
 }
 
 
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index cf78698..3d167ef 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -3949,6 +3949,13 @@
 }
 
 
+void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
+  Register result = ToRegister(instr->result());
+  Register base = ToRegister(instr->base_object());
+  __ lea(result, Operand(base, instr->offset()));
+}
+
+
 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
   Register object = ToRegister(instr->object());
   Register value = ToRegister(instr->value());
@@ -5025,12 +5032,8 @@
   // the constructor's prototype changes, but instance size and property
   // counts remain unchanged (if slack tracking finished).
   ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
-  __ AllocateInNewSpace(instance_size,
-                        result,
-                        no_reg,
-                        scratch,
-                        deferred->entry(),
-                        TAG_OBJECT);
+  __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
+              TAG_OBJECT);
 
   __ bind(deferred->exit());
   if (FLAG_debug_code) {
@@ -5119,7 +5122,10 @@
   }
   if (instr->size()->IsConstantOperand()) {
     int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
-    __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags);
+    if (instr->hydrogen()->CanAllocateInOldPointerSpace()) {
+      flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_POINTER_SPACE);
+    }
+    __ Allocate(size, result, temp, no_reg, deferred->entry(), flags);
   } else {
     Register size = ToRegister(instr->size());
     __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags);
@@ -5340,7 +5346,7 @@
   // Allocate all objects that are part of the literal in one big
   // allocation. This avoids multiple limit checks.
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
@@ -5427,7 +5433,7 @@
   __ bind(&materialized);
   int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
   Label allocated, runtime_allocate;
-  __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
+  __ Allocate(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
   __ jmp(&allocated);
 
   __ bind(&runtime_allocate);
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index 009df37..d9c2f95 100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -292,6 +292,13 @@
 }
 
 
+void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
+  stream->Add(" = ");
+  base_object()->PrintTo(stream);
+  stream->Add(" + %d", offset());
+}
+
+
 void LCallConstantFunction::PrintDataTo(StringStream* stream) {
   stream->Add("#%d / ", arity());
 }
@@ -676,8 +683,12 @@
 LUnallocated* LChunkBuilder::TempRegister() {
   LUnallocated* operand =
       new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
-  operand->set_virtual_register(allocator_->GetVirtualRegister());
-  if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
+  int vreg = allocator_->GetVirtualRegister();
+  if (!allocator_->AllocationOk()) {
+    Abort("Out of virtual registers while trying to allocate temp register.");
+    return NULL;
+  }
+  operand->set_virtual_register(vreg);
   return operand;
 }
 
@@ -938,7 +949,7 @@
   if (value->EmitAtUses()) {
     ASSERT(value->IsConstant());
     ASSERT(!value->representation().IsDouble());
-    HBasicBlock* successor = HConstant::cast(value)->ToBoolean()
+    HBasicBlock* successor = HConstant::cast(value)->BooleanValue()
         ? instr->FirstSuccessor()
         : instr->SecondSuccessor();
     return new(zone()) LGoto(successor->block_id());
@@ -1024,6 +1035,15 @@
 }
 
 
+LInstruction* LChunkBuilder::DoInnerAllocatedObject(
+    HInnerAllocatedObject* inner_object) {
+  LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
+  LInnerAllocatedObject* result =
+    new(zone()) LInnerAllocatedObject(base_object);
+  return DefineAsRegister(result);
+}
+
+
 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
   return instr->HasNoUses()
       ? NULL
diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h
index 22a1f96..9e3e836 100644
--- a/src/x64/lithium-x64.h
+++ b/src/x64/lithium-x64.h
@@ -188,7 +188,8 @@
   V(LoadFieldByIndex)                           \
   V(DateField)                                  \
   V(WrapReceiver)                               \
-  V(Drop)
+  V(Drop)                                       \
+  V(InnerAllocatedObject)
 
 
 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic)              \
@@ -1594,6 +1595,22 @@
 };
 
 
+class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
+ public:
+  explicit LInnerAllocatedObject(LOperand* base_object) {
+    inputs_[0] = base_object;
+  }
+
+  LOperand* base_object() { return inputs_[0]; }
+  int offset() { return hydrogen()->offset(); }
+
+  virtual void PrintDataTo(StringStream* stream);
+
+  DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
+  DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
+};
+
+
 class LThisFunction: public LTemplateInstruction<1, 0, 0> {
  public:
   DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
index 5a263ab..9ecf66c 100644
--- a/src/x64/macro-assembler-x64.cc
+++ b/src/x64/macro-assembler-x64.cc
@@ -551,7 +551,8 @@
 
 
 void MacroAssembler::TailCallStub(CodeStub* stub) {
-  ASSERT(allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe());
+  ASSERT(allow_stub_calls_ ||
+         stub->CompilingCallsToThisStubIsGCSafe(isolate()));
   Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET);
 }
 
@@ -564,7 +565,7 @@
 
 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) {
   if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false;
-  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe();
+  return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate());
 }
 
 
@@ -2943,6 +2944,7 @@
 
 
 void MacroAssembler::DispatchMap(Register obj,
+                                 Register unused,
                                  Handle<Map> map,
                                  Handle<Code> success,
                                  SmiCheckType smi_check_type) {
@@ -3714,8 +3716,8 @@
 void MacroAssembler::LoadAllocationTopHelper(Register result,
                                              Register scratch,
                                              AllocationFlags flags) {
-  ExternalReference new_space_allocation_top =
-      ExternalReference::new_space_allocation_top_address(isolate());
+  ExternalReference allocation_top =
+      AllocationUtils::GetAllocationTopReference(isolate(), flags);
 
   // Just return if allocation top is already known.
   if ((flags & RESULT_CONTAINS_TOP) != 0) {
@@ -3723,7 +3725,7 @@
     ASSERT(!scratch.is_valid());
 #ifdef DEBUG
     // Assert that result actually contains top on entry.
-    Operand top_operand = ExternalOperand(new_space_allocation_top);
+    Operand top_operand = ExternalOperand(allocation_top);
     cmpq(result, top_operand);
     Check(equal, "Unexpected allocation top");
 #endif
@@ -3733,40 +3735,41 @@
   // Move address of new object to result. Use scratch register if available,
   // and keep address in scratch until call to UpdateAllocationTopHelper.
   if (scratch.is_valid()) {
-    LoadAddress(scratch, new_space_allocation_top);
+    LoadAddress(scratch, allocation_top);
     movq(result, Operand(scratch, 0));
   } else {
-    Load(result, new_space_allocation_top);
+    Load(result, allocation_top);
   }
 }
 
 
 void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
-                                               Register scratch) {
+                                               Register scratch,
+                                               AllocationFlags flags) {
   if (emit_debug_code()) {
     testq(result_end, Immediate(kObjectAlignmentMask));
     Check(zero, "Unaligned allocation in new space");
   }
 
-  ExternalReference new_space_allocation_top =
-      ExternalReference::new_space_allocation_top_address(isolate());
+  ExternalReference allocation_top =
+      AllocationUtils::GetAllocationTopReference(isolate(), flags);
 
   // Update new top.
   if (scratch.is_valid()) {
     // Scratch already contains address of allocation top.
     movq(Operand(scratch, 0), result_end);
   } else {
-    Store(new_space_allocation_top, result_end);
+    Store(allocation_top, result_end);
   }
 }
 
 
-void MacroAssembler::AllocateInNewSpace(int object_size,
-                                        Register result,
-                                        Register result_end,
-                                        Register scratch,
-                                        Label* gc_required,
-                                        AllocationFlags flags) {
+void MacroAssembler::Allocate(int object_size,
+                              Register result,
+                              Register result_end,
+                              Register scratch,
+                              Label* gc_required,
+                              AllocationFlags flags) {
   ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
@@ -3795,8 +3798,8 @@
   }
 
   // Calculate new top and bail out if new space is exhausted.
-  ExternalReference new_space_allocation_limit =
-      ExternalReference::new_space_allocation_limit_address(isolate());
+  ExternalReference allocation_limit =
+      AllocationUtils::GetAllocationLimitReference(isolate(), flags);
 
   Register top_reg = result_end.is_valid() ? result_end : result;
 
@@ -3805,12 +3808,12 @@
   }
   addq(top_reg, Immediate(object_size));
   j(carry, gc_required);
-  Operand limit_operand = ExternalOperand(new_space_allocation_limit);
+  Operand limit_operand = ExternalOperand(allocation_limit);
   cmpq(top_reg, limit_operand);
   j(above, gc_required);
 
   // Update allocation top.
-  UpdateAllocationTopHelper(top_reg, scratch);
+  UpdateAllocationTopHelper(top_reg, scratch, flags);
 
   bool tag_result = (flags & TAG_OBJECT) != 0;
   if (top_reg.is(result)) {
@@ -3836,6 +3839,7 @@
                                         Label* gc_required,
                                         AllocationFlags flags) {
   ASSERT((flags & SIZE_IN_WORDS) == 0);
+  ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -3875,7 +3879,7 @@
   j(above, gc_required);
 
   // Update allocation top.
-  UpdateAllocationTopHelper(result_end, scratch);
+  UpdateAllocationTopHelper(result_end, scratch, flags);
 
   // Tag the result if requested.
   if ((flags & TAG_OBJECT) != 0) {
@@ -3892,6 +3896,7 @@
                                         Label* gc_required,
                                         AllocationFlags flags) {
   ASSERT((flags & (RESULT_CONTAINS_TOP | SIZE_IN_WORDS)) == 0);
+  ASSERT((flags & PRETENURE_OLD_POINTER_SPACE) == 0);
   if (!FLAG_inline_new) {
     if (emit_debug_code()) {
       // Trash the registers to simulate an allocation failure.
@@ -3923,7 +3928,7 @@
   j(above, gc_required);
 
   // Update allocation top.
-  UpdateAllocationTopHelper(result_end, scratch);
+  UpdateAllocationTopHelper(result_end, scratch, flags);
 
   // Align the next allocation. Storing the filler map without checking top is
   // always safe because the limit of the heap is always aligned.
@@ -3958,12 +3963,7 @@
                                         Register scratch,
                                         Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(HeapNumber::kSize,
-                     result,
-                     scratch,
-                     no_reg,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(HeapNumber::kSize, result, scratch, no_reg, gc_required, TAG_OBJECT);
 
   // Set the map.
   LoadRoot(kScratchRegister, Heap::kHeapNumberMapRootIndex);
@@ -4053,12 +4053,8 @@
                                         Register scratch2,
                                         Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   LoadRoot(kScratchRegister, Heap::kConsStringMapRootIndex);
@@ -4071,12 +4067,8 @@
                                              Register scratch2,
                                              Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(ConsString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(ConsString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   LoadRoot(kScratchRegister, Heap::kConsAsciiStringMapRootIndex);
@@ -4089,12 +4081,8 @@
                                           Register scratch2,
                                           Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   LoadRoot(kScratchRegister, Heap::kSlicedStringMapRootIndex);
@@ -4107,12 +4095,8 @@
                                                Register scratch2,
                                                Label* gc_required) {
   // Allocate heap number in new space.
-  AllocateInNewSpace(SlicedString::kSize,
-                     result,
-                     scratch1,
-                     scratch2,
-                     gc_required,
-                     TAG_OBJECT);
+  Allocate(SlicedString::kSize, result, scratch1, scratch2, gc_required,
+           TAG_OBJECT);
 
   // Set the map. The other fields are left uninitialized.
   LoadRoot(kScratchRegister, Heap::kSlicedAsciiStringMapRootIndex);
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h
index 7827feb..df52159 100644
--- a/src/x64/macro-assembler-x64.h
+++ b/src/x64/macro-assembler-x64.h
@@ -909,6 +909,7 @@
   // specified target if equal. Skip the smi check if not required (object is
   // known to be a heap object)
   void DispatchMap(Register obj,
+                   Register unused,
                    Handle<Map> map,
                    Handle<Code> success,
                    SmiCheckType smi_check_type);
@@ -1024,22 +1025,22 @@
   // ---------------------------------------------------------------------------
   // Allocation support
 
-  // Allocate an object in new space. If the new space is exhausted control
-  // continues at the gc_required label. The allocated object is returned in
-  // result and end of the new object is returned in result_end. The register
-  // scratch can be passed as no_reg in which case an additional object
-  // reference will be added to the reloc info. The returned pointers in result
-  // and result_end have not yet been tagged as heap objects. If
-  // result_contains_top_on_entry is true the content of result is known to be
-  // the allocation top on entry (could be result_end from a previous call to
-  // AllocateInNewSpace). If result_contains_top_on_entry is true scratch
+  // Allocate an object in new space or old pointer space. If the given space
+  // is exhausted control continues at the gc_required label. The allocated
+  // object is returned in result and end of the new object is returned in
+  // result_end. The register scratch can be passed as no_reg in which case
+  // an additional object reference will be added to the reloc info. The
+  // returned pointers in result and result_end have not yet been tagged as
+  // heap objects. If result_contains_top_on_entry is true the content of
+  // result is known to be the allocation top on entry (could be result_end
+  // from a previous call). If result_contains_top_on_entry is true scratch
   // should be no_reg as it is never used.
-  void AllocateInNewSpace(int object_size,
-                          Register result,
-                          Register result_end,
-                          Register scratch,
-                          Label* gc_required,
-                          AllocationFlags flags);
+  void Allocate(int object_size,
+                Register result,
+                Register result_end,
+                Register scratch,
+                Label* gc_required,
+                AllocationFlags flags);
 
   void AllocateInNewSpace(int header_size,
                           ScaleFactor element_size,
@@ -1388,9 +1389,12 @@
   void LoadAllocationTopHelper(Register result,
                                Register scratch,
                                AllocationFlags flags);
+
   // Update allocation top with value in result_end register.
   // If scratch is valid, it contains the address of the allocation top.
-  void UpdateAllocationTopHelper(Register result_end, Register scratch);
+  void UpdateAllocationTopHelper(Register result_end,
+                                 Register scratch,
+                                 AllocationFlags flags);
 
   // Helper for PopHandleScope.  Allowed to perform a GC and returns
   // NULL if gc_allowed.  Does not perform a GC if !gc_allowed, and
diff --git a/src/x64/regexp-macro-assembler-x64.cc b/src/x64/regexp-macro-assembler-x64.cc
index c9871f0..914241e 100644
--- a/src/x64/regexp-macro-assembler-x64.cc
+++ b/src/x64/regexp-macro-assembler-x64.cc
@@ -393,9 +393,6 @@
     __ j(not_equal, on_no_match);  // Definitely not equal.
     __ subb(rax, Immediate('a'));
     __ cmpb(rax, Immediate('z' - 'a'));
-#ifndef ENABLE_LATIN_1
-    __ j(above, on_no_match);  // Weren't letters anyway.
-#else
     __ j(below_equal, &loop_increment);  // In range 'a'-'z'.
     // Latin-1: Check for values in range [224,254] but not 247.
     __ subb(rax, Immediate(224 - 'a'));
@@ -403,7 +400,6 @@
     __ j(above, on_no_match);  // Weren't Latin-1 letters.
     __ cmpb(rax, Immediate(247 - 224));  // Check for 247.
     __ j(equal, on_no_match);
-#endif
     __ bind(&loop_increment);
     // Increment pointers into match and capture strings.
     __ addq(r11, Immediate(1));
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 0e8e74e..69d7a91 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -343,19 +343,6 @@
 }
 
 
-// Load a fast property out of a holder object (src). In-object properties
-// are loaded directly otherwise the property is loaded from the properties
-// fixed array.
-void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
-                                            Register dst,
-                                            Register src,
-                                            Handle<JSObject> holder,
-                                            PropertyIndex index) {
-  DoGenerateFastPropertyLoad(
-      masm, dst, src, index.is_inobject(holder), index.translate(holder));
-}
-
-
 void StubCompiler::DoGenerateFastPropertyLoad(MacroAssembler* masm,
                                               Register dst,
                                               Register src,
@@ -715,28 +702,13 @@
 };
 
 
-void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC);
-  Handle<Code> code = (kind == Code::LOAD_IC)
-      ? masm->isolate()->builtins()->LoadIC_Miss()
-      : masm->isolate()->builtins()->KeyedLoadIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateStoreMiss(MacroAssembler* masm, Code::Kind kind) {
-  ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
-  Handle<Code> code = (kind == Code::STORE_IC)
-      ? masm->isolate()->builtins()->StoreIC_Miss()
-      : masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(code, RelocInfo::CODE_TARGET);
-}
-
-
-void StubCompiler::GenerateKeyedLoadMissForceGeneric(MacroAssembler* masm) {
-  Handle<Code> code =
-      masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ Jump(code, RelocInfo::CODE_TARGET);
+void BaseStoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
+                                                Label* label,
+                                                Handle<Name> name) {
+  if (!label->is_unused()) {
+    __ bind(label);
+    __ Move(this->name(), name);
+  }
 }
 
 
@@ -749,9 +721,11 @@
                                       Handle<Name> name,
                                       Register receiver_reg,
                                       Register name_reg,
+                                      Register value_reg,
                                       Register scratch1,
                                       Register scratch2,
-                                      Label* miss_label) {
+                                      Label* miss_label,
+                                      Label* miss_restore_name) {
   LookupResult lookup(masm->isolate());
   object->Lookup(*name, &lookup);
   if (lookup.IsFound() && (lookup.IsReadOnly() || !lookup.IsCacheable())) {
@@ -785,17 +759,8 @@
         holder = JSObject::cast(holder->GetPrototype());
       } while (holder->GetPrototype()->IsJSObject());
     }
-    // We need an extra register, push
-    __ push(name_reg);
-    Label miss_pop, done_check;
     CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
-                    scratch1, scratch2, name, &miss_pop);
-    __ jmp(&done_check);
-    __ bind(&miss_pop);
-    __ pop(name_reg);
-    __ jmp(miss_label);
-    __ bind(&done_check);
-    __ pop(name_reg);
+                    scratch1, scratch2, name, miss_restore_name);
   }
 
   // Stub never generated for non-global objects that require access
@@ -809,7 +774,7 @@
     __ pop(scratch1);  // Return address.
     __ push(receiver_reg);
     __ Push(transition);
-    __ push(rax);
+    __ push(value_reg);
     __ push(scratch1);
     __ TailCallExternalReference(
         ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
@@ -843,11 +808,11 @@
   if (index < 0) {
     // Set the property straight into the object.
     int offset = object->map()->instance_size() + (index * kPointerSize);
-    __ movq(FieldOperand(receiver_reg, offset), rax);
+    __ movq(FieldOperand(receiver_reg, offset), value_reg);
 
     // Update the write barrier for the array address.
     // Pass the value being stored in the now unused name_reg.
-    __ movq(name_reg, rax);
+    __ movq(name_reg, value_reg);
     __ RecordWriteField(
         receiver_reg, offset, name_reg, scratch1, kDontSaveFPRegs);
   } else {
@@ -855,16 +820,17 @@
     int offset = index * kPointerSize + FixedArray::kHeaderSize;
     // Get the properties array (optimistically).
     __ movq(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset));
-    __ movq(FieldOperand(scratch1, offset), rax);
+    __ movq(FieldOperand(scratch1, offset), value_reg);
 
     // Update the write barrier for the array address.
     // Pass the value being stored in the now unused name_reg.
-    __ movq(name_reg, rax);
+    __ movq(name_reg, value_reg);
     __ RecordWriteField(
         scratch1, offset, name_reg, receiver_reg, kDontSaveFPRegs);
   }
 
   // Return the value (register rax).
+  ASSERT(value_reg.is(rax));
   __ ret(0);
 }
 
@@ -908,15 +874,16 @@
   }
 }
 
-#undef __
-#define __ ACCESS_MASM((masm()))
 
-
-void StubCompiler::GenerateTailCall(Handle<Code> code) {
+void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
   __ jmp(code, RelocInfo::CODE_TARGET);
 }
 
 
+#undef __
+#define __ ACCESS_MASM((masm()))
+
+
 Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
                                        Register object_reg,
                                        Handle<JSObject> holder,
@@ -1039,7 +1006,7 @@
   if (!miss->is_unused()) {
     __ jmp(success);
     __ bind(miss);
-    GenerateLoadMiss(masm(), kind());
+    TailCallBuiltin(masm(), MissBuiltin(kind()));
   }
 }
 
@@ -2408,64 +2375,26 @@
 }
 
 
-Handle<Code> StoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                  int index,
-                                                  Handle<Map> transition,
-                                                  Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : name
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
-  Label miss;
-
-  // Generate store field code.  Preserves receiver and name on jump to miss.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     rdx, rcx, rbx, rdi,
-                     &miss);
-
-  // Handle store cache miss.
-  __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreCallback(
     Handle<Name> name,
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<JSObject> holder,
     Handle<ExecutableAccessorInfo> callback) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : name
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
   Label miss;
   // Check that the maps haven't changed.
-  __ JumpIfSmi(rdx, &miss);
-  CheckPrototypes(receiver, rdx, holder, rbx, r8, rdi, name, &miss);
+  __ JumpIfSmi(receiver(), &miss);
+  CheckPrototypes(object, receiver(), holder,
+                  scratch1(), scratch2(), scratch3(), name, &miss);
 
   // Stub never generated for non-global objects that require access checks.
   ASSERT(holder->IsJSGlobalProxy() || !holder->IsAccessCheckNeeded());
 
-  __ pop(rbx);  // remove the return address
-  __ push(rdx);  // receiver
+  __ pop(scratch1());  // remove the return address
+  __ push(receiver());
   __ Push(callback);  // callback info
-  __ push(rcx);  // name
-  __ push(rax);  // value
-  __ push(rbx);  // restore return address
+  __ push(this->name());
+  __ push(value());
+  __ push(scratch1());  // restore return address
 
   // Do tail-call to the runtime system.
   ExternalReference store_callback_property =
@@ -2474,11 +2403,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
+  return GetICCode(kind(), Code::CALLBACKS, name);
 }
 
 
@@ -2528,64 +2456,30 @@
 #define __ ACCESS_MASM(masm())
 
 
-Handle<Code> StoreStubCompiler::CompileStoreViaSetter(
-    Handle<Name> name,
-    Handle<JSObject> receiver,
-    Handle<JSObject> holder,
-    Handle<JSFunction> setter) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : name
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
-  Label miss;
-
-  // Check that the maps haven't changed.
-  __ JumpIfSmi(rdx, &miss);
-  CheckPrototypes(receiver, rdx, holder, rbx, r8, rdi, name, &miss);
-
-  GenerateStoreViaSetter(masm(), setter);
-
-  __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::CALLBACKS, name);
-}
-
-
 Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
-    Handle<JSObject> receiver,
+    Handle<JSObject> object,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : name
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the object hasn't changed.
-  __ CheckMap(rdx, Handle<Map>(receiver->map()), &miss,
+  __ CheckMap(receiver(), Handle<Map>(object->map()), &miss,
               DO_SMI_CHECK, ALLOW_ELEMENT_TRANSITION_MAPS);
 
   // Perform global security token check if needed.
-  if (receiver->IsJSGlobalProxy()) {
-    __ CheckAccessGlobalProxy(rdx, rbx, &miss);
+  if (object->IsJSGlobalProxy()) {
+    __ CheckAccessGlobalProxy(receiver(), scratch1(), &miss);
   }
 
   // Stub never generated for non-global objects that require access
   // checks.
-  ASSERT(receiver->IsJSGlobalProxy() || !receiver->IsAccessCheckNeeded());
+  ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
 
-  __ pop(rbx);  // remove the return address
-  __ push(rdx);  // receiver
-  __ push(rcx);  // name
-  __ push(rax);  // value
-  __ Push(Smi::FromInt(strict_mode_));
-  __ push(rbx);  // restore return address
+  __ pop(scratch1());  // remove the return address
+  __ push(receiver());
+  __ push(this->name());
+  __ push(value());
+  __ Push(Smi::FromInt(strict_mode()));
+  __ push(scratch1());  // restore return address
 
   // Do tail-call to the runtime system.
   ExternalReference store_ic_property =
@@ -2594,11 +2488,10 @@
 
   // Handle store cache miss.
   __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::INTERCEPTOR, name);
+  return GetICCode(kind(), Code::INTERCEPTOR, name);
 }
 
 
@@ -2606,22 +2499,17 @@
     Handle<GlobalObject> object,
     Handle<JSGlobalPropertyCell> cell,
     Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : name
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
   Label miss;
 
   // Check that the map of the global has not changed.
-  __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset),
+  __ Cmp(FieldOperand(receiver(), HeapObject::kMapOffset),
          Handle<Map>(object->map()));
   __ j(not_equal, &miss);
 
   // Compute the cell operand to use.
-  __ Move(rbx, cell);
-  Operand cell_operand = FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset);
+  __ Move(scratch1(), cell);
+  Operand cell_operand =
+      FieldOperand(scratch1(), JSGlobalPropertyCell::kValueOffset);
 
   // Check that the value in the cell is not the hole. If it is, this
   // cell could have been deleted and reintroducing the global needs
@@ -2631,7 +2519,7 @@
   __ j(equal, &miss);
 
   // Store the value in the cell.
-  __ movq(cell_operand, rax);
+  __ movq(cell_operand, value());
   // Cells are always rescanned, so no write barrier here.
 
   // Return the value (register rax).
@@ -2642,78 +2530,10 @@
   // Handle store cache miss.
   __ bind(&miss);
   __ IncrementCounter(counters->named_store_global_inline_miss(), 1);
-  Handle<Code> ic = isolate()->builtins()->StoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreField(Handle<JSObject> object,
-                                                       int index,
-                                                       Handle<Map> transition,
-                                                       Handle<Name> name) {
-  // ----------- S t a t e -------------
-  //  -- rax     : value
-  //  -- rcx     : key
-  //  -- rdx     : receiver
-  //  -- rsp[0]  : return address
-  // -----------------------------------
-  Label miss;
-
-  Counters* counters = isolate()->counters();
-  __ IncrementCounter(counters->keyed_store_field(), 1);
-
-  // Check that the name has not changed.
-  __ Cmp(rcx, name);
-  __ j(not_equal, &miss);
-
-  // Generate store field code.  Preserves receiver and name on jump to miss.
-  GenerateStoreField(masm(),
-                     object,
-                     index,
-                     transition,
-                     name,
-                     rdx, rcx, rbx, rdi,
-                     &miss);
-
-  // Handle store cache miss.
-  __ bind(&miss);
-  __ DecrementCounter(counters->keyed_store_field(), 1);
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ Jump(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(transition.is_null()
-                 ? Code::FIELD
-                 : Code::MAP_TRANSITION, name);
-}
-
-
-Handle<Code> KeyedStoreStubCompiler::CompileStoreElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : key
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
-
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
-  Handle<Code> stub =
-      KeyedStoreElementStub(is_js_array,
-                            elements_kind,
-                            store_mode_).GetCode(isolate());
-
-  __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
-
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
-
-  // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string());
+  return GetICCode(kind(), Code::NORMAL, name);
 }
 
 
@@ -2721,37 +2541,34 @@
     MapHandleList* receiver_maps,
     CodeHandleList* handler_stubs,
     MapHandleList* transitioned_maps) {
-  // ----------- S t a t e -------------
-  //  -- rax    : value
-  //  -- rcx    : key
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
   Label miss;
-  __ JumpIfSmi(rdx, &miss, Label::kNear);
+  __ JumpIfSmi(receiver(), &miss, Label::kNear);
 
-  __ movq(rdi, FieldOperand(rdx, HeapObject::kMapOffset));
+  __ movq(scratch1(), FieldOperand(receiver(), HeapObject::kMapOffset));
   int receiver_count = receiver_maps->length();
   for (int i = 0; i < receiver_count; ++i) {
     // Check map and tail call if there's a match
-    __ Cmp(rdi, receiver_maps->at(i));
+    __ Cmp(scratch1(), receiver_maps->at(i));
     if (transitioned_maps->at(i).is_null()) {
       __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET);
     } else {
       Label next_map;
       __ j(not_equal, &next_map, Label::kNear);
-      __ movq(rbx, transitioned_maps->at(i), RelocInfo::EMBEDDED_OBJECT);
+      __ movq(transition_map(),
+              transitioned_maps->at(i),
+              RelocInfo::EMBEDDED_OBJECT);
       __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET);
       __ bind(&next_map);
     }
   }
 
   __ bind(&miss);
-  Handle<Code> ic = isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
-  return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
+  return GetICCode(
+      kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
 }
 
 
@@ -2789,6 +2606,20 @@
 }
 
 
+Register* StoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { rdx, rcx, rax, rbx, rdi, r8 };
+  return registers;
+}
+
+
+Register* KeyedStoreStubCompiler::registers() {
+  // receiver, name, value, scratch1, scratch2, scratch3.
+  static Register registers[] = { rdx, rcx, rax, rbx, rdi, r8 };
+  return registers;
+}
+
+
 void KeyedLoadStubCompiler::GenerateNameCheck(Handle<Name> name,
                                               Register name_reg,
                                               Label* miss) {
@@ -2797,6 +2628,14 @@
 }
 
 
+void KeyedStoreStubCompiler::GenerateNameCheck(Handle<Name> name,
+                                               Register name_reg,
+                                               Label* miss) {
+  __ Cmp(name_reg, name);
+  __ j(not_equal, miss);
+}
+
+
 #undef __
 #define __ ACCESS_MASM(masm)
 
@@ -2875,33 +2714,6 @@
 }
 
 
-Handle<Code> KeyedLoadStubCompiler::CompileLoadElement(
-    Handle<Map> receiver_map) {
-  // ----------- S t a t e -------------
-  //  -- rax    : key
-  //  -- rdx    : receiver
-  //  -- rsp[0] : return address
-  // -----------------------------------
-  ElementsKind elements_kind = receiver_map->elements_kind();
-  if (receiver_map->has_fast_elements() ||
-      receiver_map->has_external_array_elements()) {
-    Handle<Code> stub = KeyedLoadFastElementStub(
-        receiver_map->instance_type() == JS_ARRAY_TYPE,
-        elements_kind).GetCode(isolate());
-    __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
-  } else {
-    Handle<Code> stub =
-        KeyedLoadDictionaryElementStub().GetCode(isolate());
-    __ DispatchMap(rdx, receiver_map, stub, DO_SMI_CHECK);
-  }
-
-  GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
-
-  // Return the generated code.
-  return GetICCode(kind(), Code::NORMAL, factory()->empty_string());
-}
-
-
 Handle<Code> BaseLoadStubCompiler::CompilePolymorphicIC(
     MapHandleList* receiver_maps,
     CodeHandleList* handlers,
@@ -2925,7 +2737,7 @@
   }
 
   __  bind(&miss);
-  GenerateLoadMiss(masm(), kind());
+  TailCallBuiltin(masm(), MissBuiltin(kind()));
 
   // Return the generated code.
   InlineCacheState state =
@@ -2985,8 +2797,8 @@
   __ cmpq(rcx, Immediate(instance_size));
   __ Check(equal, "Instance size of initial map changed.");
 #endif
-  __ AllocateInNewSpace(instance_size, rdx, rcx, no_reg,
-                        &generic_stub_call, NO_ALLOCATION_FLAGS);
+  __ Allocate(instance_size, rdx, rcx, no_reg, &generic_stub_call,
+              NO_ALLOCATION_FLAGS);
 
   // Allocated the JSObject, now initialize the fields and add the heap tag.
   // rbx: initial map
@@ -3101,9 +2913,7 @@
   //  -- rdx    : receiver
   //  -- rsp[0]  : return address
   // -----------------------------------
-  Handle<Code> slow_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_Slow();
-  __ jmp(slow_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow);
 
   __ bind(&miss_force_generic);
   // ----------- S t a t e -------------
@@ -3111,9 +2921,7 @@
   //  -- rdx    : receiver
   //  -- rsp[0]  : return address
   // -----------------------------------
-  Handle<Code> miss_ic =
-      masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
-  __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric);
 }
 
 
@@ -3311,9 +3119,7 @@
   //  -- rdx     : receiver
   //  -- rsp[0]  : return address
   // -----------------------------------
-
-  Handle<Code> ic = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-  __ jmp(ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
 
   // Miss case: call runtime.
   __ bind(&miss_force_generic);
@@ -3324,10 +3130,7 @@
   //  -- rdx    : receiver
   //  -- rsp[0] : return address
   // -----------------------------------
-
-  Handle<Code> miss_ic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(miss_ic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 }
 
 
@@ -3396,13 +3199,10 @@
 
   // Handle store cache miss.
   __ bind(&miss_force_generic);
-  Handle<Code> ic_force_generic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -3420,7 +3220,7 @@
     __ j(not_equal, &check_capacity);
 
     int size = FixedArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, rdi, rbx, r8, &slow, TAG_OBJECT);
+    __ Allocate(size, rdi, rbx, r8, &slow, TAG_OBJECT);
 
     // rax: value
     // rcx: key
@@ -3468,8 +3268,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
@@ -3519,16 +3318,13 @@
 
   // Handle store cache miss, replacing the ic with the generic stub.
   __ bind(&miss_force_generic);
-  Handle<Code> ic_force_generic =
-      masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
-  __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_MissForceGeneric);
 
   __ bind(&restore_key_transition_elements_kind);
   // Restore smi-tagging of rcx.
   __ Integer32ToSmi(rcx, rcx);
   __ bind(&transition_elements_kind);
-  Handle<Code> ic_miss = masm->isolate()->builtins()->KeyedStoreIC_Miss();
-  __ jmp(ic_miss, RelocInfo::CODE_TARGET);
+  TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Miss);
 
   if (is_js_array && IsGrowStoreMode(store_mode)) {
     // Grow the array by a single element if possible.
@@ -3554,7 +3350,7 @@
     __ j(not_equal, &check_capacity);
 
     int size = FixedDoubleArray::SizeFor(JSArray::kPreallocatedArrayElements);
-    __ AllocateInNewSpace(size, rdi, rbx, r8, &slow, TAG_OBJECT);
+    __ Allocate(size, rdi, rbx, r8, &slow, TAG_OBJECT);
 
     // rax: value
     // rcx: key
@@ -3602,8 +3398,7 @@
     __ jmp(&finish_store);
 
     __ bind(&slow);
-    Handle<Code> ic_slow = masm->isolate()->builtins()->KeyedStoreIC_Slow();
-    __ jmp(ic_slow, RelocInfo::CODE_TARGET);
+    TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
   }
 }
 
diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc
index 0ff747c..2335d10 100644
--- a/test/cctest/test-accessors.cc
+++ b/test/cctest/test-accessors.cc
@@ -52,10 +52,10 @@
 
 
 THREADED_TEST(PropertyHandler) {
-  v8::HandleScope scope;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   fun_templ->InstanceTemplate()->SetAccessor(v8_str("foo"), handle_property);
-  LocalContext env;
   Local<Function> fun = fun_templ->GetFunction();
   env->Global()->Set(v8_str("Fun"), fun);
   Local<Script> getter = v8_compile("var obj = new Fun(); obj.foo;");
@@ -88,7 +88,7 @@
   foo = 0;
   bar = -4;
   baz = 10;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->InstanceTemplate()->SetAccessor(v8_str("foo"),
                                          GetIntValue,
@@ -136,10 +136,10 @@
 
 
 THREADED_TEST(AccessorIC) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("x"), XGetter, XSetter);
-  LocalContext context;
   x_holder = obj->NewInstance();
   context->Global()->Set(v8_str("holder"), x_holder);
   x_receiver = v8::Object::New();
@@ -169,8 +169,8 @@
 
 
 THREADED_TEST(AccessorProhibitsOverwriting) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"),
                      AccessorProhibitsOverwritingGetter,
@@ -218,17 +218,17 @@
 
 
 THREADED_TEST(HandleScopePop) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("one"), HandleAllocatingGetter<1>);
   obj->SetAccessor(v8_str("many"), HandleAllocatingGetter<1024>);
-  LocalContext context;
   v8::Handle<v8::Object> inst = obj->NewInstance();
   context->Global()->Set(v8::String::New("obj"), inst);
   i::Isolate* isolate = i::Isolate::Current();
   int count_before = i::HandleScope::NumberOfHandles(isolate);
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(context->GetIsolate());
     CompileRun(
         "for (var i = 0; i < 1000; i++) {"
         "  obj.one;"
@@ -256,13 +256,13 @@
 }
 
 THREADED_TEST(DirectCall) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("xxx"),
                    CheckAccessorArgsCorrect,
                    NULL,
                    v8::String::New("data"));
-  LocalContext context;
   v8::Handle<v8::Object> inst = obj->NewInstance();
   context->Global()->Set(v8::String::New("obj"), inst);
   Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
@@ -282,10 +282,10 @@
 }
 
 THREADED_TEST(EmptyResult) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data"));
-  LocalContext context;
   v8::Handle<v8::Object> inst = obj->NewInstance();
   context->Global()->Set(v8::String::New("obj"), inst);
   Local<Script> scr = v8::Script::Compile(v8::String::New("obj.xxx"));
@@ -299,7 +299,7 @@
 THREADED_TEST(NoReuseRegress) {
   // Check that the IC generated for the one test doesn't get reused
   // for the other.
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   {
     v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
     obj->SetAccessor(v8_str("xxx"), EmptyGetter, NULL, v8::String::New("data"));
@@ -345,14 +345,14 @@
 
 
 THREADED_TEST(Regress1054726) {
-  v8::HandleScope scope;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("x"),
                    ThrowingGetAccessor,
                    ThrowingSetAccessor,
                    Local<Value>());
 
-  LocalContext env;
   env->Global()->Set(v8_str("obj"), obj->NewInstance());
 
   // Use the throwing property setter/getter in a loop to force
@@ -382,10 +382,10 @@
 
 
 THREADED_TEST(Gc) {
-  v8::HandleScope scope;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("xxx"), AllocGetter);
-  LocalContext env;
   env->Global()->Set(v8_str("obj"), obj->NewInstance());
   Script::Compile(String::New(
       "var last = [];"
@@ -414,11 +414,11 @@
 
 
 THREADED_TEST(StackIteration) {
-  v8::HandleScope scope;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   i::StringStream::ClearMentionedObjectCache();
   obj->SetAccessor(v8_str("xxx"), StackCheck);
-  LocalContext env;
   env->Global()->Set(v8_str("obj"), obj->NewInstance());
   Script::Compile(String::New(
       "function foo() {"
@@ -442,10 +442,10 @@
 THREADED_TEST(HandleScopeSegment) {
   // Check that we can return values past popping of handle scope
   // segments.
-  v8::HandleScope scope;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("xxx"), AllocateHandles);
-  LocalContext env;
   env->Global()->Set(v8_str("obj"), obj->NewInstance());
   v8::Handle<v8::Value> result = Script::Compile(String::New(
       "var result;"
@@ -470,8 +470,8 @@
 
 
 THREADED_TEST(JSONStringifyNamedInterceptorObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetNamedPropertyHandler(
diff --git a/test/cctest/test-alloc.cc b/test/cctest/test-alloc.cc
index 8cabd3d..d71247c 100644
--- a/test/cctest/test-alloc.cc
+++ b/test/cctest/test-alloc.cc
@@ -96,7 +96,7 @@
 
 TEST(StressHandles) {
   v8::Persistent<v8::Context> env = v8::Context::New();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   env->Enter();
   Handle<Object> o = Test();
   CHECK(o->IsSmi() && Smi::cast(*o)->value() == 42);
@@ -118,7 +118,7 @@
 
 TEST(StressJS) {
   v8::Persistent<v8::Context> env = v8::Context::New();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   env->Enter();
   Handle<JSFunction> function =
       FACTORY->NewFunction(FACTORY->function_string(), FACTORY->null_value());
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index f6bee09..e06cb77 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -144,7 +144,7 @@
 
 
 THREADED_TEST(Handles) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<Context> local_env;
   {
     LocalContext env;
@@ -169,8 +169,8 @@
 
 
 THREADED_TEST(IsolateOfContext) {
-  v8::HandleScope scope;
   v8::Persistent<Context> env = Context::New();
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK(!env->InContext());
   CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
@@ -186,8 +186,8 @@
 
 
 THREADED_TEST(ReceiverSignature) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::FunctionTemplate> fun = v8::FunctionTemplate::New();
   v8::Handle<v8::Signature> sig = v8::Signature::New(fun);
   fun->PrototypeTemplate()->Set(
@@ -230,8 +230,8 @@
 
 
 THREADED_TEST(ArgumentSignature) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::FunctionTemplate> cons = v8::FunctionTemplate::New();
   cons->SetClassName(v8_str("Cons"));
   v8::Handle<v8::Signature> sig =
@@ -292,8 +292,8 @@
 
 
 THREADED_TEST(HulIgennem) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::Primitive> undef = v8::Undefined();
   Local<String> undef_str = undef->ToString();
   char* value = i::NewArray<char>(undef_str->Length() + 1);
@@ -304,8 +304,8 @@
 
 
 THREADED_TEST(Access) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::Object> obj = v8::Object::New();
   Local<Value> foo_before = obj->Get(v8_str("foo"));
   CHECK(foo_before->IsUndefined());
@@ -319,8 +319,8 @@
 
 
 THREADED_TEST(AccessElement) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::Object> obj = v8::Object::New();
   Local<Value> before = obj->Get(1);
   CHECK(before->IsUndefined());
@@ -338,8 +338,8 @@
 
 
 THREADED_TEST(Script) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const char* c_source = "1 + 2 + 3";
   Local<String> source = String::New(c_source);
   Local<Script> script = Script::Compile(source);
@@ -410,8 +410,8 @@
   const char* c_source = "1 + 2 * 3";
   uint16_t* two_byte_source = AsciiToTwoByteString(c_source);
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     TestResource* resource = new TestResource(two_byte_source, &dispose_count);
     Local<String> source = String::NewExternal(resource);
     Local<Script> script = Script::Compile(source);
@@ -438,8 +438,8 @@
   int dispose_count = 0;
   const char* c_source = "1 + 2 * 3";
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source),
                                                         &dispose_count);
     Local<String> source = String::NewExternal(resource);
@@ -467,8 +467,8 @@
   int dispose_count = 0;
   uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3");
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     Local<String> source = String::New(two_byte_source);
     // Trigger GCs so that the newly allocated string moves to old gen.
     HEAP->CollectGarbage(i::NEW_SPACE);  // in survivor space now
@@ -498,8 +498,8 @@
   int dispose_count = 0;
   const char* c_source = "1 + 2 * 3";
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     Local<String> source = v8_str(c_source);
     // Trigger GCs so that the newly allocated string moves to old gen.
     HEAP->CollectGarbage(i::NEW_SPACE);  // in survivor space now
@@ -521,8 +521,8 @@
 
 
 TEST(MakingExternalStringConditions) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Free some space in the new space so that we can check freshness.
   HEAP->CollectGarbage(i::NEW_SPACE);
@@ -567,8 +567,8 @@
 
 
 TEST(MakingExternalAsciiStringConditions) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Free some space in the new space so that we can check freshness.
   HEAP->CollectGarbage(i::NEW_SPACE);
@@ -605,7 +605,7 @@
 
 THREADED_TEST(UsingExternalString) {
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     uint16_t* two_byte_string = AsciiToTwoByteString("test string");
     Local<String> string =
         String::NewExternal(new TestResource(two_byte_string));
@@ -624,7 +624,7 @@
 
 THREADED_TEST(UsingExternalAsciiString) {
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     const char* one_byte_string = "test string";
     Local<String> string = String::NewExternal(
         new TestAsciiResource(i::StrDup(one_byte_string)));
@@ -647,7 +647,7 @@
   int dispose_count = 0;
   bool in_new_space = false;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     uint16_t* two_byte_string = AsciiToTwoByteString("test string");
     Local<String> string =
       String::NewExternal(new TestResource(two_byte_string,
@@ -669,7 +669,7 @@
   int dispose_count = 0;
   bool in_new_space = false;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     const char* one_byte_string = "test string";
     Local<String> string = String::NewExternal(
         new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count));
@@ -715,8 +715,8 @@
   TestAsciiResourceWithDisposeControl::dispose_calls = 0;
   TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false);
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     Local<String> source =  String::NewExternal(&res_stack);
     Local<Script> script = Script::Compile(source);
     Local<Value> value = script->Run();
@@ -736,8 +736,8 @@
   TestAsciiResource* res_heap =
       new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true);
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     Local<String> source =  String::NewExternal(res_heap);
     Local<Script> script = Script::Compile(source);
     Local<Value> value = script->Run();
@@ -755,8 +755,8 @@
 
 THREADED_TEST(StringConcat) {
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     const char* one_byte_string_1 = "function a_times_t";
     const char* two_byte_string_1 = "wo_plus_b(a, b) {return ";
     const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + ";
@@ -800,8 +800,8 @@
 
 
 THREADED_TEST(GlobalProperties) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::Object> global = env->Global();
   global->Set(v8_str("pi"), v8_num(3.1415926));
   Local<Value> pi = global->Get(v8_str("pi"));
@@ -829,8 +829,8 @@
 
 
 THREADED_TEST(FunctionTemplate) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   {
     Local<v8::FunctionTemplate> fun_templ =
         v8::FunctionTemplate::New(handle_call);
@@ -870,8 +870,8 @@
 
 
 THREADED_TEST(FunctionTemplateSetLength) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   {
     Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(
         handle_call, Handle<v8::Value>(), Handle<v8::Signature>(), 23);
@@ -910,8 +910,8 @@
 
 
 static void TestExternalPointerWrapping() {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Value> data = v8::External::New(expected_ptr);
 
@@ -975,8 +975,8 @@
 
 
 THREADED_TEST(FindInstanceInPrototypeChain) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> base = v8::FunctionTemplate::New();
   Local<v8::FunctionTemplate> derived = v8::FunctionTemplate::New();
@@ -1022,8 +1022,8 @@
 
 
 THREADED_TEST(TinyInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   int32_t value = 239;
@@ -1036,8 +1036,8 @@
 
 
 THREADED_TEST(BigSmiInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   int32_t value = i::Smi::kMaxValue;
@@ -1056,8 +1056,8 @@
 
 
 THREADED_TEST(BigInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   // We cannot add one to a Smi::kMaxValue without wrapping.
@@ -1079,8 +1079,8 @@
 
 
 THREADED_TEST(TinyUnsignedInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   uint32_t value = 239;
@@ -1094,8 +1094,8 @@
 
 
 THREADED_TEST(BigUnsignedSmiInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue);
@@ -1111,8 +1111,8 @@
 
 
 THREADED_TEST(BigUnsignedInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1;
@@ -1128,8 +1128,8 @@
 
 
 THREADED_TEST(OutOfSignedRangeUnsignedInteger) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
 
   uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1;
@@ -1145,8 +1145,8 @@
 
 
 THREADED_TEST(IsNativeError) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<Value> syntax_error = CompileRun(
       "var out = 0; try { eval(\"#\"); } catch(x) { out = x; } out; ");
   CHECK(syntax_error->IsNativeError());
@@ -1158,8 +1158,8 @@
 
 
 THREADED_TEST(StringObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<Value> boxed_string = CompileRun("new String(\"test\")");
   CHECK(boxed_string->IsStringObject());
   v8::Handle<Value> unboxed_string = CompileRun("\"test\"");
@@ -1183,8 +1183,8 @@
 
 
 THREADED_TEST(NumberObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<Value> boxed_number = CompileRun("new Number(42)");
   CHECK(boxed_number->IsNumberObject());
   v8::Handle<Value> unboxed_number = CompileRun("42");
@@ -1204,8 +1204,8 @@
 
 
 THREADED_TEST(BooleanObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<Value> boxed_boolean = CompileRun("new Boolean(true)");
   CHECK(boxed_boolean->IsBooleanObject());
   v8::Handle<Value> unboxed_boolean = CompileRun("true");
@@ -1229,8 +1229,8 @@
 
 
 THREADED_TEST(Number) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   double PI = 3.1415926;
   Local<v8::Number> pi_obj = v8::Number::New(PI);
   CHECK_EQ(PI, pi_obj->NumberValue());
@@ -1238,8 +1238,8 @@
 
 
 THREADED_TEST(ToNumber) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<String> str = v8_str("3.1415926");
   CHECK_EQ(3.1415926, str->NumberValue());
   v8::Handle<v8::Boolean> t = v8::True();
@@ -1250,8 +1250,8 @@
 
 
 THREADED_TEST(Date) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   double PI = 3.1415926;
   Local<Value> date = v8::Date::New(PI);
   CHECK_EQ(3.0, date->NumberValue());
@@ -1261,8 +1261,8 @@
 
 
 THREADED_TEST(Boolean) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::Boolean> t = v8::True();
   CHECK(t->Value());
   v8::Handle<v8::Boolean> f = v8::False();
@@ -1296,7 +1296,7 @@
 
 
 THREADED_TEST(GlobalPrototype) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
   func_templ->PrototypeTemplate()->Set(
       "dummy",
@@ -1314,7 +1314,7 @@
 
 
 THREADED_TEST(ObjectTemplate) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ1 = ObjectTemplate::New();
   templ1->Set("x", v8_num(10));
   templ1->Set("y", v8_num(13));
@@ -1350,7 +1350,7 @@
 
 
 THREADED_TEST(DescriptorInheritance) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New();
   super->PrototypeTemplate()->Set("flabby",
                                   v8::FunctionTemplate::New(GetFlabby));
@@ -1481,7 +1481,7 @@
 }
 
 THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1498,7 +1498,7 @@
 }
 
 THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1518,7 +1518,7 @@
 }
 
 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1537,7 +1537,7 @@
 }
 
 THREADED_TEST(SwitchFromInterceptorToAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> templ = FunctionTemplate::New();
   AddAccessor(templ, v8_str("age"),
               SimpleAccessorGetter, SimpleAccessorSetter);
@@ -1554,7 +1554,7 @@
 }
 
 THREADED_TEST(SwitchFromAccessorToInterceptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> templ = FunctionTemplate::New();
   AddAccessor(templ, v8_str("age"),
               SimpleAccessorGetter, SimpleAccessorSetter);
@@ -1571,7 +1571,7 @@
 }
 
 THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1590,7 +1590,7 @@
 }
 
 THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1609,7 +1609,7 @@
 }
 
 THREADED_TEST(SwitchFromInterceptorToJSAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> templ = FunctionTemplate::New();
   AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
   LocalContext env;
@@ -1633,7 +1633,7 @@
 }
 
 THREADED_TEST(SwitchFromJSAccessorToInterceptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> templ = FunctionTemplate::New();
   AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
   LocalContext env;
@@ -1657,7 +1657,7 @@
 }
 
 THREADED_TEST(SwitchFromInterceptorToProperty) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1674,7 +1674,7 @@
 }
 
 THREADED_TEST(SwitchFromPropertyToInterceptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> parent = FunctionTemplate::New();
   Handle<FunctionTemplate> child = FunctionTemplate::New();
   child->Inherit(parent);
@@ -1692,7 +1692,7 @@
 
 THREADED_TEST(NamedPropertyHandlerGetter) {
   echo_named_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty,
                                                      0, 0, 0, 0,
@@ -1727,7 +1727,7 @@
 
 
 THREADED_TEST(IndexedPropertyHandlerGetter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty,
                                                        0, 0, 0, 0,
@@ -1828,8 +1828,8 @@
 
 
 THREADED_TEST(PropertyHandlerInPrototype) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Set up a prototype chain with three interceptors.
   v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
@@ -1897,7 +1897,7 @@
 
 
 THREADED_TEST(PrePropertyHandler) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New();
   desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet,
                                                     0,
@@ -1915,8 +1915,8 @@
 
 
 THREADED_TEST(UndefinedIsNotEnumerable) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<Value> result = Script::Compile(v8_str(
       "this.propertyIsEnumerable(undefined)"))->Run();
   CHECK(result->IsFalse());
@@ -1952,7 +1952,7 @@
 
 
 THREADED_TEST(DeepCrossLanguageRecursion) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
   global->Set(v8_str("callScriptRecursively"),
               v8::FunctionTemplate::New(CallScriptRecursivelyCall));
@@ -1986,7 +1986,7 @@
 
 
 THREADED_TEST(CallbackExceptionRegression) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet,
                                ThrowingPropertyHandlerSet);
@@ -2002,7 +2002,7 @@
 
 
 THREADED_TEST(FunctionPrototype) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New();
   Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321));
   LocalContext env;
@@ -2013,8 +2013,8 @@
 
 
 THREADED_TEST(InternalFields) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
@@ -2028,7 +2028,7 @@
 
 
 THREADED_TEST(GlobalObjectInternalFields) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->SetInternalFieldCount(1);
   LocalContext env(NULL, global_template);
@@ -2051,8 +2051,8 @@
 
 
 THREADED_TEST(InternalFieldsAlignedPointers) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
@@ -2090,8 +2090,8 @@
 
 
 THREADED_TEST(EmbedderDataAlignedPointers) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CheckAlignedPointerInEmbedderData(&env, 0, NULL);
 
@@ -2124,8 +2124,8 @@
 }
 
 THREADED_TEST(EmbedderData) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CheckEmbedderData(&env, 3, v8::String::New("The quick brown fox jumps"));
   CheckEmbedderData(&env, 2, v8::String::New("over the lazy dog."));
@@ -2135,8 +2135,8 @@
 
 
 THREADED_TEST(IdentityHash) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Ensure that the test starts with an fresh heap to test whether the hash
   // code is based on the address.
@@ -2179,8 +2179,8 @@
 
 
 THREADED_TEST(HiddenProperties) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Local<v8::Object> obj = v8::Object::New();
   v8::Local<v8::String> key = v8_str("api-test::hidden-key");
@@ -2234,8 +2234,8 @@
   // Regression test for crbug.com/97784
   // Messing with the Object.prototype should not have effect on
   // hidden properties.
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Local<v8::Object> obj = v8::Object::New();
   v8::Local<v8::String> key = v8_str("hidden");
@@ -2267,8 +2267,8 @@
 
 
 THREADED_TEST(HiddenPropertiesWithInterceptors) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   interceptor_for_hidden_properties_called = false;
 
@@ -2287,7 +2287,7 @@
 
 
 THREADED_TEST(External) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   int x = 3;
   Local<v8::External> ext = v8::External::New(&x);
   LocalContext env;
@@ -2322,7 +2322,7 @@
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
   v8::Persistent<String> global;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     Local<String> str = v8_str("str");
     global = v8::Persistent<String>::New(isolate, str);
   }
@@ -2330,7 +2330,7 @@
   global.Dispose(isolate);
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     Local<String> str = v8_str("str");
     global = v8::Persistent<String>::New(isolate, str);
   }
@@ -2340,7 +2340,7 @@
 
 
 THREADED_TEST(LocalHandle) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
   CHECK_EQ(local->Length(), 3);
 
@@ -2372,9 +2372,9 @@
 
 
 THREADED_TEST(ApiObjectGroups) {
-  HandleScope scope;
   LocalContext env;
   v8::Isolate* iso = env->GetIsolate();
+  HandleScope scope(iso);
 
   Persistent<Object> g1s1;
   Persistent<Object> g1s2;
@@ -2386,7 +2386,7 @@
   WeakCallCounter counter(1234);
 
   {
-    HandleScope scope;
+    HandleScope scope(iso);
     g1s1 = Persistent<Object>::New(iso, Object::New());
     g1s2 = Persistent<Object>::New(iso, Object::New());
     g1c1 = Persistent<Object>::New(iso, Object::New());
@@ -2458,9 +2458,9 @@
 
 
 THREADED_TEST(ApiObjectGroupsCycle) {
-  HandleScope scope;
   LocalContext env;
   v8::Isolate* iso = env->GetIsolate();
+  HandleScope scope(iso);
 
   WeakCallCounter counter(1234);
 
@@ -2474,7 +2474,7 @@
   Persistent<Object> g4s2;
 
   {
-    HandleScope scope;
+    HandleScope scope(iso);
     g1s1 = Persistent<Object>::New(iso, Object::New());
     g1s2 = Persistent<Object>::New(iso, Object::New());
     g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
@@ -2568,9 +2568,9 @@
 TEST(ApiObjectGroupsCycleForScavenger) {
   i::FLAG_stress_compaction = false;
   i::FLAG_gc_global = false;
-  HandleScope scope;
   LocalContext env;
   v8::Isolate* iso = env->GetIsolate();
+  HandleScope scope(iso);
 
   WeakCallCounter counter(1234);
 
@@ -2582,7 +2582,7 @@
   Persistent<Object> g3s2;
 
   {
-    HandleScope scope;
+    HandleScope scope(iso);
     g1s1 = Persistent<Object>::New(iso, Object::New());
     g1s2 = Persistent<Object>::New(iso, Object::New());
     g1s1.MakeWeak(iso, reinterpret_cast<void*>(&counter), &WeakPointerCallback);
@@ -2661,8 +2661,8 @@
 
 
 THREADED_TEST(ScriptException) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<Script> script = Script::Compile(v8_str("throw 'panama!';"));
   v8::TryCatch try_catch;
   Local<Value> result = script->Run();
@@ -2674,8 +2674,8 @@
 
 
 TEST(TryCatchCustomException) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::TryCatch try_catch;
   CompileRun("function CustomError() { this.a = 'b'; }"
              "(function f() { throw new CustomError(); })();");
@@ -2699,7 +2699,7 @@
 
 THREADED_TEST(MessageHandler0) {
   message_received = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   CHECK(!message_received);
   v8::V8::AddMessageListener(check_message_0, v8_num(5.76));
   LocalContext context;
@@ -2725,7 +2725,7 @@
 
 TEST(MessageHandler1) {
   message_received = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   CHECK(!message_received);
   v8::V8::AddMessageListener(check_message_1);
   LocalContext context;
@@ -2749,7 +2749,7 @@
 
 TEST(MessageHandler2) {
   message_received = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   CHECK(!message_received);
   v8::V8::AddMessageListener(check_message_2);
   LocalContext context;
@@ -2765,8 +2765,8 @@
 
 
 THREADED_TEST(GetSetProperty) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   context->Global()->Set(v8_str("foo"), v8_num(14));
   context->Global()->Set(v8_str("12"), v8_num(92));
   context->Global()->Set(v8::Integer::New(16), v8_num(32));
@@ -2792,8 +2792,8 @@
 
 
 THREADED_TEST(PropertyAttributes) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   // none
   Local<String> prop = v8_str("none");
   context->Global()->Set(prop, v8_num(7));
@@ -2836,8 +2836,8 @@
 
 
 THREADED_TEST(Array) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<v8::Array> array = v8::Array::New();
   CHECK_EQ(0, array->Length());
   CHECK(array->Get(0)->IsUndefined());
@@ -2864,7 +2864,7 @@
 
 
 v8::Handle<Value> HandleF(const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   ApiTestFuzzer::Fuzz();
   Local<v8::Array> result = v8::Array::New(args.Length());
   for (int i = 0; i < args.Length(); i++)
@@ -2874,7 +2874,7 @@
 
 
 THREADED_TEST(Vector) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> global = ObjectTemplate::New();
   global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF));
   LocalContext context(0, global);
@@ -2912,8 +2912,8 @@
 
 
 THREADED_TEST(FunctionCall) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   CompileRun(
     "function Foo() {"
     "  var result = [];"
@@ -2980,8 +2980,8 @@
   v8::SetResourceConstraints(&constraints);
 
   // Execute a script that causes out of memory.
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::V8::IgnoreOutOfMemoryException();
   Local<Script> script =
       Script::Compile(String::New(js_code_causing_out_of_memory));
@@ -2996,8 +2996,8 @@
 v8::Handle<Value> ProvokeOutOfMemory(const v8::Arguments& args) {
   ApiTestFuzzer::Fuzz();
 
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<Script> script =
       Script::Compile(String::New(js_code_causing_out_of_memory));
   Local<Value> result = script->Run();
@@ -3020,7 +3020,7 @@
   constraints.set_max_old_space_size(4 * K * K);
   v8::SetResourceConstraints(&constraints);
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ProvokeOutOfMemory"),
              v8::FunctionTemplate::New(ProvokeOutOfMemory));
@@ -3052,8 +3052,8 @@
   // Execute a script that causes out of memory.
   v8::V8::IgnoreOutOfMemoryException();
 
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   // Build huge string. This should fail with out of memory exception.
   Local<Value> result = CompileRun(
@@ -3067,8 +3067,8 @@
 
 
 THREADED_TEST(ConstructCall) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   CompileRun(
     "function Foo() {"
     "  var result = [];"
@@ -3127,8 +3127,8 @@
 
 
 THREADED_TEST(ConversionNumber) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   // Very large number.
   CompileRun("var obj = Math.pow(2,32) * 1237;");
   Local<Value> obj = env->Global()->Get(v8_str("obj"));
@@ -3175,8 +3175,8 @@
 
 
 THREADED_TEST(isNumberType) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   // Very large number.
   CompileRun("var obj = Math.pow(2,32) * 1237;");
   Local<Value> obj = env->Global()->Get(v8_str("obj"));
@@ -3226,8 +3226,8 @@
 
 
 THREADED_TEST(ConversionException) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun(
     "function TestClass() { };"
     "TestClass.prototype.toString = function () { throw 'uncle?'; };"
@@ -3287,7 +3287,7 @@
 
 v8::Handle<Value> CCatcher(const v8::Arguments& args) {
   if (args.Length() < 1) return v8::False();
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   v8::TryCatch try_catch;
   Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run();
   CHECK(!try_catch.HasCaught() || result.IsEmpty());
@@ -3296,7 +3296,7 @@
 
 
 THREADED_TEST(APICatch) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ThrowFromC"),
              v8::FunctionTemplate::New(ThrowFromC));
@@ -3314,7 +3314,7 @@
 
 
 THREADED_TEST(APIThrowTryCatch) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ThrowFromC"),
              v8::FunctionTemplate::New(ThrowFromC));
@@ -3333,7 +3333,7 @@
 // JS stack.  This test therefore fails on the simulator.  The test is
 // not threaded to allow the threading tests to run on the simulator.
 TEST(TryCatchInTryFinally) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("CCatcher"),
              v8::FunctionTemplate::New(CCatcher));
@@ -3368,7 +3368,7 @@
 // formatting. However, they are invoked when performing normal error
 // string conversions.
 TEST(APIThrowMessageOverwrittenToString) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::V8::AddMessageListener(check_reference_error_message);
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail));
@@ -3414,9 +3414,9 @@
 
 
 TEST(CustomErrorToString) {
-  v8::HandleScope scope;
-  v8::V8::AddMessageListener(check_custom_error_message);
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
+  v8::V8::AddMessageListener(check_custom_error_message);
   CompileRun(
     "function MyError(name, message) {                   "
     "  this.name = name;                                 "
@@ -3440,7 +3440,7 @@
 
 TEST(APIThrowMessage) {
   message_received = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::V8::AddMessageListener(receive_message);
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ThrowFromC"),
@@ -3454,7 +3454,7 @@
 
 TEST(APIThrowMessageAndVerboseTryCatch) {
   message_received = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::V8::AddMessageListener(receive_message);
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ThrowFromC"),
@@ -3472,9 +3472,9 @@
 
 TEST(APIStackOverflowAndVerboseTryCatch) {
   message_received = false;
-  v8::HandleScope scope;
-  v8::V8::AddMessageListener(receive_message);
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
+  v8::V8::AddMessageListener(receive_message);
   v8::TryCatch try_catch;
   try_catch.SetVerbose(true);
   Local<Value> result = CompileRun("function foo() { foo(); } foo();");
@@ -3486,7 +3486,7 @@
 
 
 THREADED_TEST(ExternalScriptException) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("ThrowFromC"),
              v8::FunctionTemplate::New(ThrowFromC));
@@ -3553,8 +3553,8 @@
 
 
 THREADED_TEST(EvalInTryFinally) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   CompileRun("(function() {"
              "  try {"
@@ -3588,7 +3588,7 @@
 // JS stack.  This test therefore fails on the simulator.  The test is
 // not threaded to allow the threading tests to run on the simulator.
 TEST(ExceptionOrder) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck));
   templ->Set(v8_str("CThrowCountDown"),
@@ -3652,7 +3652,7 @@
 
 
 THREADED_TEST(ThrowValues) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue));
   LocalContext context(0, templ);
@@ -3678,8 +3678,8 @@
 
 
 THREADED_TEST(CatchZero) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   CHECK(!try_catch.HasCaught());
   Script::Compile(v8_str("throw 10"))->Run();
@@ -3694,8 +3694,8 @@
 
 
 THREADED_TEST(CatchExceptionFromWith) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   CHECK(!try_catch.HasCaught());
   Script::Compile(v8_str("var o = {}; with (o) { throw 42; }"))->Run();
@@ -3704,8 +3704,8 @@
 
 
 THREADED_TEST(TryCatchAndFinallyHidingException) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   CHECK(!try_catch.HasCaught());
   CompileRun("function f(k) { try { this[k]; } finally { return 0; } };");
@@ -3721,8 +3721,8 @@
 
 
 THREADED_TEST(TryCatchAndFinally) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   context->Global()->Set(
       v8_str("native_with_try_catch"),
       v8::FunctionTemplate::New(WithTryCatch)->GetFunction());
@@ -3753,8 +3753,8 @@
 
 TEST(TryCatchNested) {
   v8::V8::Initialize();
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   TryCatchNestedHelper(5);
   CHECK(try_catch.HasCaught());
@@ -3763,9 +3763,9 @@
 
 
 THREADED_TEST(Equality) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(context->GetIsolate());
   // Check that equality works at all before relying on CHECK_EQ
   CHECK(v8_str("a")->Equals(v8_str("a")));
   CHECK(!v8_str("a")->Equals(v8_str("b")));
@@ -3797,8 +3797,8 @@
 
 
 THREADED_TEST(MultiRun) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<Script> script = Script::Compile(v8_str("x"));
   for (int i = 0; i < 10; i++)
     script->Run();
@@ -3815,10 +3815,10 @@
 
 
 THREADED_TEST(SimplePropertyRead) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
-  LocalContext context;
   context->Global()->Set(v8_str("obj"), templ->NewInstance());
   Local<Script> script = Script::Compile(v8_str("obj.x"));
   for (int i = 0; i < 10; i++) {
@@ -3828,10 +3828,10 @@
 }
 
 THREADED_TEST(DefinePropertyOnAPIAccessor) {
-  v8::HandleScope scope;
+  LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
-  LocalContext context;
   context->Global()->Set(v8_str("obj"), templ->NewInstance());
 
   // Uses getOwnPropertyDescriptor to check the configurable status
@@ -3875,7 +3875,7 @@
 }
 
 THREADED_TEST(DefinePropertyOnDefineGetterSetter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut"));
   LocalContext context;
@@ -3927,7 +3927,7 @@
 
 
 THREADED_TEST(DefineAPIAccessorOnObject) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   LocalContext context;
 
@@ -4001,7 +4001,7 @@
 
 
 THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   LocalContext context;
 
@@ -4057,7 +4057,7 @@
 
 
 THREADED_TEST(ElementAPIAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   LocalContext context;
 
@@ -4095,7 +4095,7 @@
 
 
 THREADED_TEST(SimplePropertyWrite) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut"));
   LocalContext context;
@@ -4112,7 +4112,7 @@
 
 
 THREADED_TEST(SetterOnly) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut"));
   LocalContext context;
@@ -4129,7 +4129,7 @@
 
 
 THREADED_TEST(NoAccessors) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"), NULL, NULL, v8_str("donut"));
   LocalContext context;
@@ -4150,7 +4150,7 @@
 
 
 THREADED_TEST(NamedInterceptorPropertyRead) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(XPropertyGetter);
   LocalContext context;
@@ -4164,7 +4164,7 @@
 
 
 THREADED_TEST(NamedInterceptorDictionaryIC) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(XPropertyGetter);
   LocalContext context;
@@ -4194,7 +4194,7 @@
 
 
 THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   v8::Persistent<Context> context1 = Context::New();
 
@@ -4248,7 +4248,7 @@
 // This is a regression test for http://crbug.com/20104. Map
 // transitions should not interfere with post interceptor lookup.
 THREADED_TEST(NamedInterceptorMapTransitionRead) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<v8::FunctionTemplate> function_template = v8::FunctionTemplate::New();
   Local<v8::ObjectTemplate> instance_template
       = function_template->InstanceTemplate();
@@ -4285,7 +4285,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithIndexedAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IndexedPropertyGetter,
                                    IndexedPropertySetter);
@@ -4352,7 +4352,7 @@
 // Make sure that the the interceptor code in the runtime properly handles
 // merging property name lists for double-array-backed arrays.
 THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(UnboxedDoubleIndexedPropertyGetter,
                                    UnboxedDoubleIndexedPropertySetter,
@@ -4404,7 +4404,7 @@
 // Make sure that the the interceptor code in the runtime properly handles
 // merging property name lists for non-string arguments arrays.
 THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(NonStrictIndexedPropertyGetter,
                                    0,
@@ -4430,7 +4430,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithGetOwnPropertyDescriptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4451,7 +4451,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithNoSetter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4474,7 +4474,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithAccessorCheck) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4499,7 +4499,7 @@
 
 THREADED_TEST(IndexedInterceptorWithAccessorCheckSwitchedOn) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4528,7 +4528,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithDifferentIndices) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4551,7 +4551,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithNegativeIndices) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4590,7 +4590,7 @@
 
 
 THREADED_TEST(IndexedInterceptorWithNotSmiLookup) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4619,7 +4619,7 @@
 
 
 THREADED_TEST(IndexedInterceptorGoingMegamorphic) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4649,7 +4649,7 @@
 
 
 THREADED_TEST(IndexedInterceptorReceiverTurningSmi) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4679,7 +4679,7 @@
 
 
 THREADED_TEST(IndexedInterceptorOnProto) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(IdentityIndexedPropertyGetter);
 
@@ -4703,7 +4703,7 @@
 
 
 THREADED_TEST(MultiContexts) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("dummy"), v8::FunctionTemplate::New(DummyCallHandler));
 
@@ -4739,7 +4739,7 @@
   // Make sure that functions created by cloning boilerplates cannot
   // communicate through their __proto__ field.
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   LocalContext env0;
   v8::Handle<v8::Object> global0 =
@@ -4772,7 +4772,7 @@
   // to Object.prototype and Array.prototype and create a new
   // environment. This should succeed.
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   Local<String> source = v8_str("Object.prototype.obj = 1234;"
                                 "Array.prototype.arr = 4567;"
@@ -4789,8 +4789,8 @@
 
 
 THREADED_TEST(UndetectableObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> desc =
       v8::FunctionTemplate::New(0, v8::Handle<Value>());
@@ -4833,8 +4833,8 @@
 
 
 THREADED_TEST(VoidLiteral) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> desc =
       v8::FunctionTemplate::New(0, v8::Handle<Value>());
@@ -4877,8 +4877,8 @@
 
 
 THREADED_TEST(ExtensibleOnUndetectable) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<v8::FunctionTemplate> desc =
       v8::FunctionTemplate::New(0, v8::Handle<Value>());
@@ -4910,8 +4910,8 @@
 
 
 THREADED_TEST(UndetectableString) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<String> obj = String::NewUndetectable("foo");
   env->Global()->Set(v8_str("undetectable"), obj);
@@ -4951,8 +4951,8 @@
 
 TEST(UndetectableOptimized) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   Local<String> obj = String::NewUndetectable("foo");
   env->Global()->Set(v8_str("undetectable"), obj);
@@ -5007,7 +5007,7 @@
 
 
 THREADED_TEST(GlobalObjectTemplate) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> global_template = ObjectTemplate::New();
   global_template->Set(v8_str("JSNI_Log"),
                        v8::FunctionTemplate::New(HandleLogDelegator));
@@ -5025,7 +5025,7 @@
 
 
 THREADED_TEST(SimpleExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("simpletest", kSimpleExtensionSource));
   const char* extension_names[] = { "simpletest" };
   v8::ExtensionConfiguration extensions(1, extension_names);
@@ -5037,7 +5037,7 @@
 
 
 THREADED_TEST(NullExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("nulltest", NULL));
   const char* extension_names[] = { "nulltest" };
   v8::ExtensionConfiguration extensions(1, extension_names);
@@ -5055,7 +5055,7 @@
 
 
 THREADED_TEST(ExtensionMissingSourceLength) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("srclentest_fail",
                                       kEmbeddedExtensionSource));
   const char* extension_names[] = { "srclentest_fail" };
@@ -5068,7 +5068,7 @@
 THREADED_TEST(ExtensionWithSourceLength) {
   for (int source_len = kEmbeddedExtensionSourceValidLen - 1;
        source_len <= kEmbeddedExtensionSourceValidLen + 1; ++source_len) {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
     i::ScopedVector<char> extension_name(32);
     i::OS::SNPrintF(extension_name, "ext #%d", source_len);
     v8::RegisterExtension(new Extension(extension_name.start(),
@@ -5107,7 +5107,7 @@
 
 
 THREADED_TEST(UseEvalFromExtension) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("evaltest1", kEvalExtensionSource1));
   v8::RegisterExtension(new Extension("evaltest2", kEvalExtensionSource2));
   const char* extension_names[] = { "evaltest1", "evaltest2" };
@@ -5140,7 +5140,7 @@
 
 
 THREADED_TEST(UseWithFromExtension) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("withtest1", kWithExtensionSource1));
   v8::RegisterExtension(new Extension("withtest2", kWithExtensionSource2));
   const char* extension_names[] = { "withtest1", "withtest2" };
@@ -5155,7 +5155,7 @@
 
 
 THREADED_TEST(AutoExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   Extension* extension = new Extension("autotest", kSimpleExtensionSource);
   extension->set_auto_enable(true);
   v8::RegisterExtension(extension);
@@ -5173,7 +5173,7 @@
 // Test that a syntax error in an extension does not cause a fatal
 // error but results in an empty context.
 THREADED_TEST(SyntaxErrorExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("syntaxerror",
                                       kSyntaxErrorInExtensionSource));
   const char* extension_names[] = { "syntaxerror" };
@@ -5190,7 +5190,7 @@
 // Test that an exception when installing an extension does not cause
 // a fatal error but results in an empty context.
 THREADED_TEST(ExceptionExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("exception",
                                       kExceptionInExtensionSource));
   const char* extension_names[] = { "exception" };
@@ -5211,7 +5211,7 @@
 
 // Test that a native runtime calls are supported in extensions.
 THREADED_TEST(NativeCallInExtensions) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::RegisterExtension(new Extension("nativecall",
                                       kNativeCallInExtensionSource));
   const char* extension_names[] = { "nativecall" };
@@ -5246,7 +5246,7 @@
 
 
 THREADED_TEST(NativeFunctionDeclaration) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   const char* name = "nativedecl";
   v8::RegisterExtension(new NativeFunctionExtension(name,
                                                     "native function foo();"));
@@ -5260,7 +5260,7 @@
 
 
 THREADED_TEST(NativeFunctionDeclarationError) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   const char* name = "nativedeclerr";
   // Syntax error in extension code.
   v8::RegisterExtension(new NativeFunctionExtension(name,
@@ -5273,7 +5273,7 @@
 
 
 THREADED_TEST(NativeFunctionDeclarationErrorEscape) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   const char* name = "nativedeclerresc";
   // Syntax error in extension code - escape code in "native" means that
   // it's not treated as a keyword.
@@ -5288,7 +5288,7 @@
 
 
 static void CheckDependencies(const char* name, const char* expected) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::ExtensionConfiguration config(1, &name);
   LocalContext context(&config);
   CHECK_EQ(String::New(expected), context->Global()->Get(v8_str("loaded")));
@@ -5316,7 +5316,7 @@
   CheckDependencies("C", "undefinedAC");
   CheckDependencies("D", "undefinedABCD");
   CheckDependencies("E", "undefinedABCDE");
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   static const char* exts[2] = { "C", "E" };
   v8::ExtensionConfiguration config(2, exts);
   LocalContext context(&config);
@@ -5371,7 +5371,7 @@
 
 THREADED_TEST(FunctionLookup) {
   v8::RegisterExtension(new FunctionExtension());
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   static const char* exts[1] = { "functiontest" };
   v8::ExtensionConfiguration config(1, exts);
   LocalContext context(&config);
@@ -5384,7 +5384,7 @@
 
 THREADED_TEST(NativeFunctionConstructCall) {
   v8::RegisterExtension(new FunctionExtension());
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   static const char* exts[1] = { "functiontest" };
   v8::ExtensionConfiguration config(1, exts);
   LocalContext context(&config);
@@ -5443,7 +5443,7 @@
 
 TEST(RegexpOutOfMemory) {
   // Execute a script that causes out of memory when flattening a string.
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::V8::SetFatalErrorHandler(OOMCallback);
   LocalContext context;
   Local<Script> script =
@@ -5465,8 +5465,8 @@
 
 
 THREADED_TEST(ErrorWithMissingScriptInfo) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::V8::AddMessageListener(MissingScriptInfoMessageListener);
   Script::Compile(v8_str("throw Error()"))->Run();
   v8::V8::RemoveMessageListeners(MissingScriptInfoMessageListener);
@@ -5530,7 +5530,7 @@
 }
 
 THREADED_TEST(WeakReference) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ= v8::ObjectTemplate::New();
   Whammy* whammy = new Whammy(v8::Isolate::GetCurrent());
   templ->SetNamedPropertyHandler(WhammyPropertyGetter,
@@ -5576,7 +5576,7 @@
   v8::Persistent<v8::Object> object_a, object_b;
 
   {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(iso);
     object_a = v8::Persistent<v8::Object>::New(iso, v8::Object::New());
     object_b = v8::Persistent<v8::Object>::New(iso, v8::Object::New());
   }
@@ -5641,7 +5641,7 @@
     for (int inner_gc = 0; inner_gc < kNumberOfGCTypes; inner_gc++) {
       v8::Persistent<v8::Object> object;
       {
-        v8::HandleScope handle_scope;
+        v8::HandleScope handle_scope(isolate);
         object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
       }
       bool disposed = false;
@@ -5669,7 +5669,7 @@
 
   v8::Persistent<v8::Object> object;
   {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     object->Set(v8_str("x"), v8::Integer::New(1));
     v8::Local<String> y_str = v8_str("y");
@@ -5682,7 +5682,7 @@
   CHECK(revived);
   HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
   {
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     v8::Local<String> y_str = v8_str("y");
     CHECK_EQ(v8::Integer::New(1), object->Get(v8_str("x")));
     CHECK(object->Get(y_str)->Equals(y_str));
@@ -5701,14 +5701,14 @@
   CHECK_EQ(v8::Integer::New(2), args[1]);
   CHECK_EQ(v8::Integer::New(3), args[2]);
   CHECK_EQ(v8::Undefined(), args[3]);
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
   return v8::Undefined();
 }
 
 
 THREADED_TEST(Arguments) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New();
   global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback));
   LocalContext context(NULL, global);
@@ -5749,7 +5749,7 @@
 
 
 THREADED_TEST(Deleter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetNamedPropertyHandler(NoBlockGetterX, NULL, NULL, PDeleter, NULL);
   obj->SetIndexedPropertyHandler(NoBlockGetterI, NULL, NULL, IDeleter, NULL);
@@ -5812,7 +5812,7 @@
 
 
 THREADED_TEST(Enumerators) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetNamedPropertyHandler(GetK, NULL, NULL, NULL, NamedEnum);
   obj->SetIndexedPropertyHandler(IndexedGetK, NULL, NULL, NULL, IndexedEnum);
@@ -5926,7 +5926,7 @@
 
 
 THREADED_TEST(GetterHolders) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("p1"), PGetter);
   obj->SetAccessor(v8_str("p2"), PGetter);
@@ -5939,7 +5939,7 @@
 
 
 THREADED_TEST(PreInterceptorHolders) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetNamedPropertyHandler(PGetter2);
   p_getter_count2 = 0;
@@ -5949,13 +5949,13 @@
 
 
 THREADED_TEST(ObjectInstantiation) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("t"), PGetter2);
   LocalContext context;
   context->Global()->Set(v8_str("o"), templ->NewInstance());
   for (int i = 0; i < 100; i++) {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     v8::Handle<v8::Object> obj = templ->NewInstance();
     CHECK_NE(obj, context->Global()->Get(v8_str("o")));
     context->Global()->Set(v8_str("o2"), obj);
@@ -6001,7 +6001,7 @@
 
 THREADED_TEST(StringWrite) {
   LocalContext context;
-  v8::HandleScope scope;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<String> str = v8_str("abcde");
   // abc<Icelandic eth><Unicode snowman>.
   v8::Handle<String> str2 = v8_str("abc\303\260\342\230\203");
@@ -6259,10 +6259,6 @@
       Local<v8::String>::Cast(a->Get(i));
     Local<v8::Number> expected_len =
       Local<v8::Number>::Cast(alens->Get(i));
-#ifndef ENABLE_LATIN_1
-    CHECK_EQ(expected_len->Value() != string->Length(),
-             string->MayContainNonAscii());
-#endif
     int length = GetUtf8Length(string);
     CHECK_EQ(static_cast<int>(expected_len->Value()), length);
   }
@@ -6349,7 +6345,7 @@
 
 THREADED_TEST(Utf16) {
   LocalContext context;
-  v8::HandleScope scope;
+  v8::HandleScope scope(context->GetIsolate());
   CompileRun(
       "var pad = '01234567890123456789';"
       "var p = [];"
@@ -6415,7 +6411,7 @@
 
 THREADED_TEST(Utf16Symbol) {
   LocalContext context;
-  v8::HandleScope scope;
+  v8::HandleScope scope(context->GetIsolate());
 
   Handle<String> symbol1 = v8::String::NewSymbol("abc");
   Handle<String> symbol2 = v8::String::NewSymbol("abc");
@@ -6467,8 +6463,8 @@
 
 
 THREADED_TEST(ToArrayIndex) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   v8::Handle<String> str = v8_str("42");
   v8::Handle<v8::Uint32> index = str->ToArrayIndex();
@@ -6498,8 +6494,8 @@
 
 
 THREADED_TEST(ErrorConstruction) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   v8::Handle<String> foo = v8_str("foo");
   v8::Handle<String> message = v8_str("message");
@@ -6538,7 +6534,7 @@
 
 
 THREADED_TEST(DeleteAccessor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
   obj->SetAccessor(v8_str("y"), YGetter, YSetter);
   LocalContext context;
@@ -6551,7 +6547,7 @@
 
 
 THREADED_TEST(TypeSwitch) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> templ1 = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> templ2 = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> templ3 = v8::FunctionTemplate::New();
@@ -6629,8 +6625,8 @@
 // also have uncaught exceptions.
 TEST(ApiUncaughtException) {
   report_count = 0;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
 
   Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
@@ -6668,8 +6664,8 @@
 }
 
 TEST(ExceptionInNativeScript) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::AddMessageListener(ExceptionInNativeScriptTestListener);
 
   Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
@@ -6688,8 +6684,8 @@
 
 
 TEST(CompilationErrorUsingTryCatchHandler) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::TryCatch try_catch;
   Script::Compile(v8_str("This doesn't &*&@#$&*^ compile."));
   CHECK_NE(NULL, *try_catch.Exception());
@@ -6698,8 +6694,8 @@
 
 
 TEST(TryCatchFinallyUsingTryCatchHandler) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::TryCatch try_catch;
   Script::Compile(v8_str("try { throw ''; } catch (e) {}"))->Run();
   CHECK(!try_catch.HasCaught());
@@ -6719,7 +6715,7 @@
 
 // SecurityHandler can't be run twice
 TEST(SecurityHandler) {
-  v8::HandleScope scope0;
+  v8::HandleScope scope0(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback,
                                            IndexedSecurityTestCallback);
@@ -6738,7 +6734,7 @@
   CHECK_EQ(999, z0->Int32Value());
 
   // Create another environment, should fail security checks.
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   v8::Persistent<Context> context1 =
     Context::New(NULL, global_template);
@@ -6759,7 +6755,7 @@
 
   // Create another environment, should pass security checks.
   { g_security_callback_result = true;  // allow security handler to pass.
-    v8::HandleScope scope2;
+    v8::HandleScope scope2(v8::Isolate::GetCurrent());
     LocalContext context2;
     v8::Handle<v8::Object> global2 = context2->Global();
     global2->Set(v8_str("othercontext"), global0);
@@ -6781,8 +6777,8 @@
 
 
 THREADED_TEST(SecurityChecks) {
-  v8::HandleScope handle_scope;
   LocalContext env1;
+  v8::HandleScope handle_scope(env1->GetIsolate());
   v8::Persistent<Context> env2 = Context::New();
 
   Local<Value> foo = v8_str("foo");
@@ -6826,8 +6822,8 @@
 
 // Regression test case for issue 1183439.
 THREADED_TEST(SecurityChecksForPrototypeChain) {
-  v8::HandleScope scope;
   LocalContext current;
+  v8::HandleScope scope(current->GetIsolate());
   v8::Persistent<Context> other = Context::New();
 
   // Change context to be able to get to the Object function in the
@@ -6894,8 +6890,8 @@
 
 
 THREADED_TEST(CrossDomainDelete) {
-  v8::HandleScope handle_scope;
   LocalContext env1;
+  v8::HandleScope handle_scope(env1->GetIsolate());
   v8::Persistent<Context> env2 = Context::New();
 
   Local<Value> foo = v8_str("foo");
@@ -6927,8 +6923,8 @@
 
 
 THREADED_TEST(CrossDomainIsPropertyEnumerable) {
-  v8::HandleScope handle_scope;
   LocalContext env1;
+  v8::HandleScope handle_scope(env1->GetIsolate());
   v8::Persistent<Context> env2 = Context::New();
 
   Local<Value> foo = v8_str("foo");
@@ -6962,8 +6958,8 @@
 
 
 THREADED_TEST(CrossDomainForIn) {
-  v8::HandleScope handle_scope;
   LocalContext env1;
+  v8::HandleScope handle_scope(env1->GetIsolate());
   v8::Persistent<Context> env2 = Context::New();
 
   Local<Value> foo = v8_str("foo");
@@ -6995,8 +6991,8 @@
 
 
 TEST(ContextDetachGlobal) {
-  v8::HandleScope handle_scope;
   LocalContext env1;
+  v8::HandleScope handle_scope(env1->GetIsolate());
   v8::Persistent<Context> env2 = Context::New();
 
   Local<v8::Object> global1 = env1->Global();
@@ -7059,8 +7055,8 @@
 
 
 TEST(DetachAndReattachGlobal) {
-  v8::HandleScope scope;
   LocalContext env1;
+  v8::HandleScope scope(env1->GetIsolate());
 
   // Create second environment.
   v8::Persistent<Context> env2 = Context::New();
@@ -7185,7 +7181,7 @@
 
 
 TEST(AccessControl) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
 
   global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
@@ -7231,7 +7227,7 @@
   Local<Value> el_getter = global0->Get(v8_str("el_getter"));
   Local<Value> el_setter = global0->Get(v8_str("el_setter"));
 
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   v8::Persistent<Context> context1 = Context::New();
   context1->Enter();
@@ -7429,7 +7425,7 @@
 
 
 TEST(AccessControlES5) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
 
   global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
@@ -7515,7 +7511,7 @@
 
 
 THREADED_TEST(AccessControlGetOwnPropertyNames) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
 
   obj_template->Set(v8_str("x"), v8::Integer::New(42));
@@ -7528,7 +7524,7 @@
 
   v8::Handle<v8::Object> global0 = context0->Global();
 
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   v8::Persistent<Context> context1 = Context::New();
   context1->Enter();
@@ -7574,7 +7570,7 @@
 
 
 THREADED_TEST(GetOwnPropertyNamesWithInterceptor) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
 
   obj_template->Set(v8_str("7"), v8::Integer::New(7));
@@ -7609,7 +7605,7 @@
 
 
 THREADED_TEST(CrossDomainAccessors) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
 
@@ -7639,7 +7635,7 @@
   global->Set(v8_str("accessible"), v8_num(11));
 
   // Enter a new context.
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
   v8::Persistent<Context> context1 = Context::New();
   context1->Enter();
 
@@ -7687,7 +7683,7 @@
   named_access_count = 0;
   indexed_access_count = 0;
 
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   // Create an environment.
   v8::Persistent<Context> context0 = Context::New();
@@ -7700,7 +7696,7 @@
                                            IndexedAccessCounter);
   Local<v8::Object> object = object_template->NewInstance();
 
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   // Create another environment.
   v8::Persistent<Context> context1 = Context::New();
@@ -7836,7 +7832,7 @@
   named_access_count = 0;
   indexed_access_count = 0;
 
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   // Create an environment.
   v8::Persistent<Context> context0 = Context::New();
@@ -7849,7 +7845,7 @@
                                            IndexedAccessFlatten);
   Local<v8::Object> object = object_template->NewInstance();
 
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   // Create another environment.
   v8::Persistent<Context> context1 = Context::New();
@@ -7900,7 +7896,7 @@
   named_access_count = 0;
   indexed_access_count = 0;
 
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   // Create an environment.
   v8::Persistent<Context> context0 = Context::New();
@@ -7918,7 +7914,7 @@
                                              AccessControlIndexedSetter);
   Local<v8::Object> object = object_template->NewInstance();
 
-  v8::HandleScope scope1;
+  v8::HandleScope scope1(v8::Isolate::GetCurrent());
 
   // Create another environment.
   v8::Persistent<Context> context1 = Context::New();
@@ -7975,8 +7971,8 @@
 
 
 THREADED_TEST(InstanceProperties) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
   Local<ObjectTemplate> instance = t->InstanceTemplate();
@@ -8004,7 +8000,7 @@
 
 
 THREADED_TEST(GlobalObjectInstanceProperties) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   Local<Value> global_object;
 
@@ -8060,7 +8056,7 @@
 
 
 THREADED_TEST(CallKnownGlobalReceiver) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   Local<Value> global_object;
 
@@ -8138,7 +8134,7 @@
 
 THREADED_TEST(ShadowObject) {
   shadow_y = shadow_y_setter_call_count = shadow_y_getter_call_count = 0;
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   Local<ObjectTemplate> global_template = v8::ObjectTemplate::New();
   LocalContext context(NULL, global_template);
@@ -8178,8 +8174,8 @@
 
 
 THREADED_TEST(HiddenPrototype) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
   t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
@@ -8222,8 +8218,8 @@
 
 
 THREADED_TEST(HiddenPrototypeSet) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> ot = v8::FunctionTemplate::New();
   Local<v8::FunctionTemplate> ht = v8::FunctionTemplate::New();
@@ -8264,8 +8260,8 @@
 
 // Regression test for issue 2457.
 THREADED_TEST(HiddenPrototypeIdentityHash) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Handle<FunctionTemplate> t = FunctionTemplate::New();
   t->SetHiddenPrototype(true);
@@ -8282,8 +8278,8 @@
 
 
 THREADED_TEST(SetPrototype) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
   t0->InstanceTemplate()->Set(v8_str("x"), v8_num(0));
@@ -8343,8 +8339,8 @@
 // crash the runtime.
 THREADED_TEST(Regress91517) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
   t1->SetHiddenPrototype(true);
@@ -8393,8 +8389,8 @@
 
 
 THREADED_TEST(FunctionReadOnlyPrototype) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t1 = v8::FunctionTemplate::New();
   t1->PrototypeTemplate()->Set(v8_str("x"), v8::Integer::New(42));
@@ -8424,8 +8420,8 @@
 
 
 THREADED_TEST(SetPrototypeThrows) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
 
@@ -8445,8 +8441,8 @@
 
 
 THREADED_TEST(GetterSetterExceptions) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
   CompileRun(
     "function Foo() { };"
     "function Throw() { throw 5; };"
@@ -8468,8 +8464,8 @@
 
 
 THREADED_TEST(Constructor) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->SetClassName(v8_str("Fun"));
   Local<Function> cons = templ->GetFunction();
@@ -8509,8 +8505,8 @@
 
 
 THREADED_TEST(ConstructorForObject) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
 
   { Local<ObjectTemplate> instance_template = ObjectTemplate::New();
     instance_template->SetCallAsFunctionHandler(ConstructorCallback);
@@ -8676,8 +8672,8 @@
 
 
 THREADED_TEST(FunctionDescriptorException) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->SetClassName(v8_str("Fun"));
   Local<Function> cons = templ->GetFunction();
@@ -8701,8 +8697,8 @@
 
 
 THREADED_TEST(EvalAliasedDynamic) {
-  v8::HandleScope scope;
   LocalContext current;
+  v8::HandleScope scope(current->GetIsolate());
 
   // Tests where aliased eval can only be resolved dynamically.
   Local<Script> script =
@@ -8737,7 +8733,7 @@
 
 
 THREADED_TEST(CrossEval) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext other;
   LocalContext current;
 
@@ -8820,7 +8816,7 @@
 // its global throws an exception.  This behavior is consistent with
 // other JavaScript implementations.
 THREADED_TEST(EvalInDetachedGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   v8::Persistent<Context> context0 = Context::New();
   v8::Persistent<Context> context1 = Context::New();
@@ -8855,7 +8851,7 @@
 
 
 THREADED_TEST(CrossLazyLoad) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext other;
   LocalContext current;
 
@@ -8890,8 +8886,8 @@
 // non-function objects created through the API to be called as
 // functions.
 THREADED_TEST(CallAsFunction) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   { Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New();
     Local<ObjectTemplate> instance_template = t->InstanceTemplate();
@@ -9003,8 +8999,8 @@
 
 // Check whether a non-function object is callable.
 THREADED_TEST(CallableObject) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   { Local<ObjectTemplate> instance_template = ObjectTemplate::New();
     instance_template->SetCallAsFunctionHandler(call_as_function);
@@ -9050,7 +9046,7 @@
 
 
 static int Recurse(int depth, int iterations) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   if (depth == 0) return CountHandles();
   for (int i = 0; i < iterations; i++) {
     Local<v8::Number> n(v8::Integer::New(42));
@@ -9064,7 +9060,7 @@
   static const int kNesting = 200;
   CHECK_EQ(0, CountHandles());
   {
-    v8::HandleScope scope1;
+    v8::HandleScope scope1(v8::Isolate::GetCurrent());
     CHECK_EQ(0, CountHandles());
     for (int i = 0; i < kIterations; i++) {
       Local<v8::Number> n(v8::Integer::New(42));
@@ -9073,7 +9069,7 @@
 
     CHECK_EQ(kIterations, CountHandles());
     {
-      v8::HandleScope scope2;
+      v8::HandleScope scope2(v8::Isolate::GetCurrent());
       for (int j = 0; j < kIterations; j++) {
         Local<v8::Number> n(v8::Integer::New(42));
         CHECK_EQ(j + 1 + kIterations, CountHandles());
@@ -9095,8 +9091,8 @@
 
 
 THREADED_TEST(InterceptorHasOwnProperty) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
   instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetter);
@@ -9127,8 +9123,8 @@
 
 
 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate();
   instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC);
@@ -9162,7 +9158,7 @@
 static void CheckInterceptorLoadIC(NamedPropertyGetter getter,
                                    const char* source,
                                    int expected) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(getter, 0, 0, 0, 0, v8_str("data"));
   LocalContext context;
@@ -9371,7 +9367,7 @@
 
 
 THREADED_TEST(InterceptorLoadICWithCallbackOnHolder) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   templ->SetAccessor(v8_str("y"), Return239);
@@ -9400,7 +9396,7 @@
 
 
 THREADED_TEST(InterceptorLoadICWithCallbackOnProto) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
@@ -9433,7 +9429,7 @@
 
 
 THREADED_TEST(InterceptorLoadICForCallbackWithOverride) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   templ->SetAccessor(v8_str("y"), Return239);
@@ -9461,7 +9457,7 @@
 // Test the case when we stored callback into
 // a stub, but interceptor produced value on its own.
 THREADED_TEST(InterceptorLoadICCallbackNotNeeded) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
@@ -9489,7 +9485,7 @@
 // Test the case when we stored callback into
 // a stub, but it got invalidated later on.
 THREADED_TEST(InterceptorLoadICInvalidatedCallback) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
@@ -9521,7 +9517,7 @@
 // a stub, but it got invalidated later on due to override on
 // global object which is between interceptor and callbacks' holders.
 THREADED_TEST(InterceptorLoadICInvalidatedCallbackViaGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   v8::Handle<v8::ObjectTemplate> templ_p = ObjectTemplate::New();
@@ -9573,7 +9569,7 @@
 
 // This test should hit the store IC for the interceptor case.
 THREADED_TEST(InterceptorStoreIC) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorLoadICGetter,
                                  InterceptorStoreICSetter,
@@ -9588,7 +9584,7 @@
 
 
 THREADED_TEST(InterceptorStoreICWithNoSetter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   LocalContext context;
@@ -9618,7 +9614,7 @@
 
 // This test should hit the call IC for the interceptor case.
 THREADED_TEST(InterceptorCallIC) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorCallICGetter);
   LocalContext context;
@@ -9637,7 +9633,7 @@
 // This test checks that if interceptor doesn't provide
 // a value, we can fetch regular value.
 THREADED_TEST(InterceptorCallICSeesOthers) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -9665,7 +9661,7 @@
 // even if we cached shadowed variant, interceptor's function
 // is invoked
 THREADED_TEST(InterceptorCallICCacheableNotNeeded) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorCallICGetter4);
   LocalContext context;
@@ -9685,7 +9681,7 @@
 // Test the case when we stored cacheable lookup into
 // a stub, but it got invalidated later on
 THREADED_TEST(InterceptorCallICInvalidatedCacheable) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -9712,7 +9708,7 @@
 // This test checks that if interceptor doesn't provide a function,
 // cached constant function is used
 THREADED_TEST(InterceptorCallICConstantFunctionUsed) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -9744,7 +9740,7 @@
 // even if we cached constant function, interceptor's function
 // is invoked
 THREADED_TEST(InterceptorCallICConstantFunctionNotNeeded) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorCallICGetter5);
   LocalContext context;
@@ -9778,7 +9774,7 @@
 // to test the optimized compiler.
 THREADED_TEST(InterceptorCallICConstantFunctionNotNeededWrapped) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorCallICGetter6);
   LocalContext context;
@@ -9808,7 +9804,7 @@
 // Test the case when we stored constant function into
 // a stub, but it got invalidated later on
 THREADED_TEST(InterceptorCallICInvalidatedConstantFunction) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -9838,7 +9834,7 @@
 // a stub, but it got invalidated later on due to override on
 // global object which is between interceptor and constant function' holders.
 THREADED_TEST(InterceptorCallICInvalidatedConstantFunctionViaGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -9863,7 +9859,7 @@
 
 // Test the case when actual function to call sits on global object.
 THREADED_TEST(InterceptorCallICCachedFromGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(NoBlockGetterX);
 
@@ -9947,8 +9943,8 @@
 
 
 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
   nativeobject_templ->Set("callback",
                           v8::FunctionTemplate::New(DirectApiCallback));
@@ -9971,8 +9967,8 @@
 
 
 THREADED_TEST(CallICFastApi_DirectCall_Throw) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New();
   nativeobject_templ->Set("callback",
                           v8::FunctionTemplate::New(ThrowingDirectApiCallback));
@@ -10002,8 +9998,8 @@
 
 
 THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
   obj->SetAccessor(v8_str("p1"), DirectGetterCallback);
   context->Global()->Set(v8_str("o1"), obj->NewInstance());
@@ -10024,8 +10020,8 @@
 
 
 THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
   obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
   context->Global()->Set(v8_str("o1"), obj->NewInstance());
@@ -10041,7 +10037,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
@@ -10068,7 +10064,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10099,7 +10095,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10136,7 +10132,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10173,7 +10169,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10213,7 +10209,7 @@
 
 THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
   int interceptor_call_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10252,7 +10248,7 @@
 }
 
 THREADED_TEST(CallICFastApi_TrivialSignature) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_TrivialSignature,
@@ -10276,7 +10272,7 @@
 }
 
 THREADED_TEST(CallICFastApi_SimpleSignature) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10304,7 +10300,7 @@
 }
 
 THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10337,7 +10333,7 @@
 }
 
 THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10373,7 +10369,7 @@
 }
 
 THREADED_TEST(CallICFastApi_SimpleSignature_TypeError) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::FunctionTemplate> method_templ =
       v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
@@ -10424,7 +10420,7 @@
 // Test the case when we stored cacheable lookup into
 // a stub, but the function name changed (to another cacheable function).
 THREADED_TEST(InterceptorKeyedCallICKeyChange1) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -10448,7 +10444,7 @@
 // a stub, but the function name changed (and the new function is present
 // both before and after the interceptor in the prototype chain).
 THREADED_TEST(InterceptorKeyedCallICKeyChange2) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorKeyedCallICGetter);
   LocalContext context;
@@ -10475,7 +10471,7 @@
 // Same as InterceptorKeyedCallICKeyChange1 only the cacheable function sit
 // on the global object.
 THREADED_TEST(InterceptorKeyedCallICKeyChangeOnGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -10500,7 +10496,7 @@
 
 // Test the case when actual function to call sits on global object.
 THREADED_TEST(InterceptorKeyedCallICFromGlobal) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -10524,7 +10520,7 @@
 
 // Test the map transition before the interceptor.
 THREADED_TEST(InterceptorKeyedCallICMapChangeBefore) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -10546,7 +10542,7 @@
 
 // Test the map transition after the interceptor.
 THREADED_TEST(InterceptorKeyedCallICMapChangeAfter) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ_o = ObjectTemplate::New();
   templ_o->SetNamedPropertyHandler(NoBlockGetterX);
   LocalContext context;
@@ -10582,7 +10578,7 @@
 // Once in a while, the interceptor will reply that a property was not
 // found in which case we should get a reference error.
 THREADED_TEST(InterceptorICReferenceErrors) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorICRefErrorGetter);
   LocalContext context(0, templ, v8::Handle<Value>());
@@ -10629,7 +10625,7 @@
 // exception once in a while.
 THREADED_TEST(InterceptorICGetterExceptions) {
   interceptor_ic_exception_get_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(InterceptorICExceptionGetter);
   LocalContext context(0, templ, v8::Handle<Value>());
@@ -10672,7 +10668,7 @@
 // once in a while.
 THREADED_TEST(InterceptorICSetterExceptions) {
   interceptor_ic_exception_set_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(0, InterceptorICExceptionSetter);
   LocalContext context(0, templ, v8::Handle<Value>());
@@ -10690,7 +10686,7 @@
 
 // Test that we ignore null interceptors.
 THREADED_TEST(NullNamedInterceptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(0);
   LocalContext context;
@@ -10705,7 +10701,7 @@
 
 // Test that we ignore null interceptors.
 THREADED_TEST(NullIndexedInterceptor) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(0);
   LocalContext context;
@@ -10719,7 +10715,7 @@
 
 
 THREADED_TEST(NamedPropertyHandlerGetterAttributes) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->InstanceTemplate()->SetNamedPropertyHandler(InterceptorLoadXICGetter);
   LocalContext env;
@@ -10739,8 +10735,8 @@
 
 
 THREADED_TEST(VariousGetPropertiesAndThrowingCallbacks) {
-  HandleScope scope;
   LocalContext context;
+  HandleScope scope(context->GetIsolate());
 
   Local<FunctionTemplate> templ = FunctionTemplate::New();
   Local<ObjectTemplate> instance_templ = templ->InstanceTemplate();
@@ -10830,8 +10826,8 @@
 }
 
 THREADED_TEST(ExceptionsDoNotPropagatePastTryCatch) {
-  HandleScope scope;
   LocalContext context;
+  HandleScope scope(context->GetIsolate());
 
   Local<Function> func =
       FunctionTemplate::New(ThrowingCallbackWithTryCatch)->GetFunction();
@@ -10874,8 +10870,8 @@
 
 THREADED_TEST(Overriding) {
   i::FLAG_es5_readonly = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   // Parent template.
   Local<v8::FunctionTemplate> parent_templ = v8::FunctionTemplate::New();
@@ -10937,7 +10933,7 @@
 
 
 THREADED_TEST(IsConstructCall) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   // Function template with call handler.
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
@@ -10954,7 +10950,7 @@
 
 
 THREADED_TEST(ObjectProtoToString) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
   templ->SetClassName(v8_str("MyClass"));
 
@@ -10988,8 +10984,8 @@
 
 
 THREADED_TEST(ObjectGetConstructorName) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8_compile("function Parent() {};"
              "function Child() {};"
              "Child.prototype = new Parent();"
@@ -11180,7 +11176,7 @@
   const char* code = "throw 7;";
   {
     v8::Locker nested_locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(args.GetIsolate());
     v8::Handle<Value> exception;
     { v8::TryCatch try_catch;
       v8::Handle<Value> value = CompileRun(code);
@@ -11203,7 +11199,7 @@
   const char* code = "throw 7;";
   {
     v8::Locker nested_locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(args.GetIsolate());
     v8::Handle<Value> value = CompileRun(code);
     CHECK(value.IsEmpty());
     return v8_str("foo");
@@ -11216,8 +11212,8 @@
 TEST(NestedLockers) {
   v8::Locker locker(CcTest::default_isolate());
   CHECK(v8::Locker::IsLocked(CcTest::default_isolate()));
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(ThrowInJS);
   Local<Function> fun = fun_templ->GetFunction();
   env->Global()->Set(v8_str("throw_in_js"), fun);
@@ -11237,8 +11233,8 @@
 // as part of the locking aggregation tests.
 TEST(NestedLockersNoTryCatch) {
   v8::Locker locker(CcTest::default_isolate());
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ =
       v8::FunctionTemplate::New(ThrowInJSNoCatch);
   Local<Function> fun = fun_templ->GetFunction();
@@ -11274,7 +11270,7 @@
 THREADED_TEST(LockUnlockLock) {
   {
     v8::Locker locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(CcTest::default_isolate());
     LocalContext env;
     Local<v8::FunctionTemplate> fun_templ =
         v8::FunctionTemplate::New(UnlockForAMoment);
@@ -11288,7 +11284,7 @@
   }
   {
     v8::Locker locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(CcTest::default_isolate());
     LocalContext env;
     Local<v8::FunctionTemplate> fun_templ =
         v8::FunctionTemplate::New(UnlockForAMoment);
@@ -11335,27 +11331,27 @@
   v8::V8::Initialize();
 
   for (int i = 0; i < 5; i++) {
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       LocalContext context;
     }
     v8::V8::ContextDisposedNotification();
     CheckSurvivingGlobalObjectsCount(0);
 
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       LocalContext context;
       v8_compile("Date")->Run();
     }
     v8::V8::ContextDisposedNotification();
     CheckSurvivingGlobalObjectsCount(0);
 
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       LocalContext context;
       v8_compile("/aaa/")->Run();
     }
     v8::V8::ContextDisposedNotification();
     CheckSurvivingGlobalObjectsCount(0);
 
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       const char* extension_list[] = { "v8/gc" };
       v8::ExtensionConfiguration extensions(1, extension_list);
       LocalContext context(&extensions);
@@ -11373,7 +11369,7 @@
 void NewPersistentHandleCallback(v8::Isolate* isolate,
                                  v8::Persistent<v8::Value> handle,
                                  void*) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(isolate);
   bad_handle = v8::Persistent<v8::Object>::New(isolate, some_object);
   handle.Dispose(isolate);
 }
@@ -11385,7 +11381,7 @@
 
   v8::Persistent<v8::Object> handle1, handle2;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     some_object = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
@@ -11417,7 +11413,7 @@
 
   v8::Persistent<v8::Object> handle1, handle2;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
   }
@@ -11435,7 +11431,7 @@
 void HandleCreatingCallback(v8::Isolate* isolate,
                             v8::Persistent<v8::Value> handle,
                             void*) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(isolate);
   v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
   handle.Dispose(isolate);
 }
@@ -11447,7 +11443,7 @@
 
   v8::Persistent<v8::Object> handle1, handle2, handle3;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     handle3 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     handle2 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
     handle1 = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
@@ -11469,11 +11465,11 @@
 
   for (int i = 0; i < nof; i++) {
     const char* source = sources[i];
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       LocalContext context;
       CompileRun(source);
     }
-    { v8::HandleScope scope;
+    { v8::HandleScope scope(v8::Isolate::GetCurrent());
       LocalContext context;
       CompileRun(source);
     }
@@ -11482,7 +11478,7 @@
 
 
 static v8::Handle<Value> NestedScope(v8::Persistent<Context> env) {
-  v8::HandleScope inner;
+  v8::HandleScope inner(env->GetIsolate());
   env->Enter();
   v8::Handle<Value> three = v8_num(3);
   v8::Handle<Value> value = inner.Close(three);
@@ -11492,7 +11488,7 @@
 
 
 THREADED_TEST(NestedHandleScopeAndContexts) {
-  v8::HandleScope outer;
+  v8::HandleScope outer(v8::Isolate::GetCurrent());
   v8::Persistent<Context> env = Context::New();
   env->Enter();
   v8::Handle<Value> value = NestedScope(env);
@@ -11531,7 +11527,7 @@
   bar_ptr = NULL;
   foo_ptr = NULL;
 
-  v8::HandleScope outer;
+  v8::HandleScope outer(v8::Isolate::GetCurrent());
   v8::Persistent<Context> env = Context::New();
   env->Enter();
 
@@ -11771,7 +11767,7 @@
   isolate->Enter();
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     i::HashMap code(MatchPointers);
     code_map = &code;
 
@@ -11824,7 +11820,7 @@
   // Verify that we get callbacks for existing code objects when we
   // request enumeration of existing code.
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate);
     LocalContext env;
     CompileRun(script);
 
@@ -11857,20 +11853,21 @@
 
 
 THREADED_TEST(ExternalAllocatedMemory) {
-  v8::HandleScope outer;
+  v8::HandleScope outer(v8::Isolate::GetCurrent());
   v8::Persistent<Context> env(Context::New());
   CHECK(!env.IsEmpty());
   const intptr_t kSize = 1024*1024;
-  CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(kSize)),
+  v8::Isolate* isolate = env->GetIsolate();
+  CHECK_EQ(cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize)),
            cast(kSize));
-  CHECK_EQ(cast(v8::V8::AdjustAmountOfExternalAllocatedMemory(-kSize)),
+  CHECK_EQ(cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)),
            cast(0));
 }
 
 
 THREADED_TEST(DisposeEnteredContext) {
-  v8::HandleScope scope;
   LocalContext outer;
+  v8::HandleScope scope(outer->GetIsolate());
   { v8::Persistent<v8::Context> inner = v8::Context::New();
     inner->Enter();
     inner.Dispose(inner->GetIsolate());
@@ -11884,12 +11881,12 @@
 // but no accessors or interceptors did not get their internal field
 // count set on instances.
 THREADED_TEST(Regress54) {
-  v8::HandleScope outer;
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope outer(isolate);
   static v8::Persistent<v8::ObjectTemplate> templ;
   if (templ.IsEmpty()) {
-    v8::HandleScope inner;
+    v8::HandleScope inner(isolate);
     v8::Handle<v8::ObjectTemplate> local = v8::ObjectTemplate::New();
     local->SetInternalFieldCount(1);
     templ =
@@ -11903,8 +11900,8 @@
 // If part of the threaded tests, this test makes ThreadingTest fail
 // on mac.
 TEST(CatchStackOverflow) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
     "function f() {"
@@ -11920,7 +11917,7 @@
 static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script,
                                     const char* resource_name,
                                     int line_offset) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::TryCatch try_catch;
   v8::Handle<v8::Value> result = script->Run();
   CHECK(result.IsEmpty());
@@ -11940,8 +11937,8 @@
 
 
 THREADED_TEST(TryCatchSourceInfo) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::String> source = v8::String::New(
       "function Foo() {\n"
       "  return Bar();\n"
@@ -11976,8 +11973,8 @@
 
 
 THREADED_TEST(CompilationCache) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::String> source0 = v8::String::New("1234");
   v8::Handle<v8::String> source1 = v8::String::New("1234");
   v8::Handle<v8::Script> script0 =
@@ -11999,8 +11996,8 @@
 
 
 THREADED_TEST(CallbackFunctionName) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> t = ObjectTemplate::New();
   t->Set(v8_str("asdf"), v8::FunctionTemplate::New(FunctionNameCallback));
   context->Global()->Set(v8_str("obj"), t->NewInstance());
@@ -12012,8 +12009,8 @@
 
 
 THREADED_TEST(DateAccess) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::Value> date = v8::Date::New(1224744689038.0);
   CHECK(date->IsDate());
   CHECK_EQ(1224744689038.0, date.As<v8::Date>()->NumberValue());
@@ -12045,8 +12042,8 @@
 
 
 THREADED_TEST(PropertyEnumeration) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New(
       "var result = [];"
       "result[0] = {};"
@@ -12079,8 +12076,8 @@
 }
 
 THREADED_TEST(PropertyEnumeration2) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New(
       "var result = [];"
       "result[0] = {};"
@@ -12121,8 +12118,8 @@
 
 
 THREADED_TEST(DisableAccessChecksWhileConfiguring) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessCheckCallbacks(NamedSetAccessBlocker,
                                  IndexedSetAccessBlocker);
@@ -12152,8 +12149,8 @@
 
 
 THREADED_TEST(AccessChecksReenabledCorrectly) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessCheckCallbacks(NamedGetAccessBlocker,
                                  IndexedGetAccessBlocker);
@@ -12191,7 +12188,7 @@
 // This tests that access check information remains on the global
 // object template when creating contexts.
 THREADED_TEST(AccessControlRepeatedContextCreation) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker,
                                            IndexedSetAccessBlocker);
@@ -12208,7 +12205,7 @@
 
 
 THREADED_TEST(TurnOnAccessCheck) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   // Create an environment with access check to the global object disabled by
   // default.
@@ -12288,7 +12285,7 @@
 
 
 THREADED_TEST(TurnOnAccessCheckAndRecompile) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
 
   // Create an environment with access check to the global object disabled by
   // default. When the registered access checker will block access to properties
@@ -12452,8 +12449,8 @@
 // Attempts to deserialize bad data.
 TEST(PreCompileInvalidPreparseDataError) {
   v8::V8::Initialize();
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   const char* script = "function foo(){ return 5;}\n"
       "function bar(){ return 6 + 7;}  foo();";
@@ -12499,7 +12496,7 @@
 // the same results (at least for one trivial case).
 TEST(PreCompileAPIVariationsAreSame) {
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   const char* cstring = "function foo(a) { return a+1; }";
 
@@ -12536,7 +12533,7 @@
 // arise because we share code between contexts via the compilation
 // cache.
 THREADED_TEST(DictionaryICLoadedFunction) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   // Test LoadIC.
   for (int i = 0; i < 2; i++) {
     LocalContext context;
@@ -12557,7 +12554,7 @@
 // Test that cross-context new calls use the context of the callee to
 // create the new JavaScript object.
 THREADED_TEST(CrossContextNew) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Persistent<Context> context0 = Context::New();
   v8::Persistent<Context> context1 = Context::New();
 
@@ -12692,7 +12689,7 @@
 TEST(RegExpInterruption) {
   v8::Locker lock(CcTest::default_isolate());
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(CcTest::default_isolate());
   Local<Context> local_env;
   {
     LocalContext env;
@@ -12801,7 +12798,7 @@
 TEST(ApplyInterruption) {
   v8::Locker lock(CcTest::default_isolate());
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(CcTest::default_isolate());
   Local<Context> local_env;
   {
     LocalContext env;
@@ -12821,8 +12818,8 @@
 
 // Verify that we can clone an object
 TEST(ObjectClone) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* sample =
     "var rv = {};"      \
@@ -12909,8 +12906,8 @@
                          " to come to the aid of the party";
   uint16_t* two_byte_string = AsciiToTwoByteString(c_string);
   {
-    v8::HandleScope scope;
     LocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     AsciiVectorResource ascii_resource(
         i::Vector<const char>(c_string, i::StrLength(c_string)));
     UC16VectorResource uc16_resource(
@@ -12930,10 +12927,8 @@
         "var slice = lhs.substring(1, lhs.length - 1);"
         "var slice_on_cons = (lhs + rhs).substring(1, lhs.length *2 - 1);");
 
-#ifndef ENABLE_LATIN_1
-    CHECK(!lhs->MayContainNonAscii());
-    CHECK(!rhs->MayContainNonAscii());
-#endif
+    CHECK(lhs->IsOneByte());
+    CHECK(rhs->IsOneByte());
 
     MorphAString(*v8::Utils::OpenHandle(*lhs), &ascii_resource, &uc16_resource);
     MorphAString(*v8::Utils::OpenHandle(*rhs), &ascii_resource, &uc16_resource);
@@ -12974,8 +12969,8 @@
 
 
 TEST(CompileExternalTwoByteSource) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   // This is a very short list of sources, which currently is to check for a
   // regression caused by r2703.
@@ -13083,7 +13078,7 @@
            morphs_ < kMaxModifications) {
       int morphs_before = morphs_;
       {
-        v8::HandleScope scope;
+        v8::HandleScope scope(v8::Isolate::GetCurrent());
         // Match 15-30 "a"'s against 14 and a "b".
         const char* c_source =
             "/a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaa/"
@@ -13116,7 +13111,7 @@
 TEST(RegExpStringModification) {
   v8::Locker lock(CcTest::default_isolate());
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(CcTest::default_isolate());
   Local<Context> local_env;
   {
     LocalContext env;
@@ -13138,7 +13133,7 @@
 // is a read-only property in the prototype chain.
 TEST(ReadOnlyPropertyInGlobalProto) {
   i::FLAG_es5_readonly = true;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
   LocalContext context(0, templ);
   v8::Handle<v8::Object> global = context->Global();
@@ -13191,7 +13186,7 @@
   force_set_set_count = 0;
   pass_on_get = false;
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
   v8::Handle<v8::String> access_property = v8::String::New("a");
   templ->SetAccessor(access_property, ForceSetGetter, ForceSetSetter);
@@ -13232,7 +13227,7 @@
   force_set_set_count = 0;
   pass_on_get = false;
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
   templ->SetNamedPropertyHandler(ForceSetGetter, ForceSetInterceptSetter);
   LocalContext context(NULL, templ);
@@ -13275,7 +13270,7 @@
 
 
 THREADED_TEST(ForceDelete) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
   LocalContext context(NULL, templ);
   v8::Handle<v8::Object> global = context->Global();
@@ -13313,7 +13308,7 @@
   force_delete_interceptor_count = 0;
   pass_on_delete = false;
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
   templ->SetNamedPropertyHandler(0, 0, 0, ForceDeleteDeleter);
   LocalContext context(NULL, templ);
@@ -13345,8 +13340,8 @@
 // Make sure that forcing a delete invalidates any IC stubs, so we
 // don't read the hole value.
 THREADED_TEST(ForceDeleteIC) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   // Create a DontDelete variable on the global object.
   CompileRun("this.__proto__ = { foo: 'horse' };"
              "var foo = 'fish';"
@@ -13366,13 +13361,13 @@
 
 TEST(InlinedFunctionAcrossContexts) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> ctx1 = v8::Context::New();
   v8::Persistent<v8::Context> ctx2 = v8::Context::New();
   ctx1->Enter();
 
   {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     CompileRun("var G = 42; function foo() { return G; }");
     v8::Local<v8::Value> foo = ctx1->Global()->Get(v8_str("foo"));
     ctx2->Enter();
@@ -13422,7 +13417,7 @@
 
 
 THREADED_TEST(GetCallingContext) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   calling_context0 = Context::New();
   calling_context1 = Context::New();
@@ -13472,8 +13467,8 @@
 // value does shadow an existing property in the prototype chain.
 THREADED_TEST(InitGlobalVarInProtoChain) {
   i::FLAG_es52_globals = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   // Introduce a variable in the prototype chain.
   CompileRun("__proto__.x = 42");
   v8::Handle<v8::Value> result = CompileRun("var x = 43; x");
@@ -13488,8 +13483,8 @@
 // original should not affect the clone.
 // See http://code.google.com/p/v8/issues/detail?id=398
 THREADED_TEST(ReplaceConstantFunction) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::Object> obj = v8::Object::New();
   v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New();
   v8::Handle<v8::String> foo_string = v8::String::New("foo");
@@ -13502,8 +13497,8 @@
 
 // Regression test for http://crbug.com/16276.
 THREADED_TEST(Regress16276) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   // Force the IC in f to be a dictionary load IC.
   CompileRun("function f(obj) { return obj.x; }\n"
              "var obj = { x: { foo: 42 }, y: 87 };\n"
@@ -13519,8 +13514,8 @@
 
 
 THREADED_TEST(PixelArray) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   const int kElementCount = 260;
   uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
   i::Handle<i::ExternalPixelArray> pixels =
@@ -13909,8 +13904,8 @@
 
 
 THREADED_TEST(PixelArrayInfo) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   for (int size = 0; size < 100; size += 10) {
     uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size));
     v8::Handle<v8::Object> obj = v8::Object::New();
@@ -13941,8 +13936,8 @@
 
 
 THREADED_TEST(PixelArrayWithInterceptor) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   const int kElementCount = 260;
   uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
   i::Handle<i::ExternalPixelArray> pixels =
@@ -14005,8 +14000,8 @@
 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
                                     int64_t low,
                                     int64_t high) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   const int kElementCount = 40;
   int element_size = ExternalArrayElementSize(array_type);
   ElementType* array_data =
@@ -14576,8 +14571,8 @@
 
 
 void ExternalArrayInfoTestHelper(v8::ExternalArrayType array_type) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   for (int size = 0; size < 100; size += 10) {
     int element_size = ExternalArrayElementSize(array_type);
     void* external_data = malloc(size * element_size);
@@ -14618,8 +14613,8 @@
 
 
 TEST(ExternalArrayLimits) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0x40000000);
   ExternalArrayLimitTestHelper(v8::kExternalByteArray, 0xffffffff);
   ExternalArrayLimitTestHelper(v8::kExternalUnsignedByteArray, 0x40000000);
@@ -14642,8 +14637,8 @@
 
 
 THREADED_TEST(ScriptContextDependence) {
-  v8::HandleScope scope;
   LocalContext c1;
+  v8::HandleScope scope(c1->GetIsolate());
   const char *source = "foo";
   v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source));
   v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source));
@@ -14658,8 +14653,8 @@
 
 
 THREADED_TEST(StackTrace) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
   const char *source = "function foo() { FAIL.FAIL; }; foo();";
   v8::Handle<v8::String> src = v8::String::New(source);
@@ -14676,7 +14671,7 @@
     const char* expected_func_name, int expected_line_number,
     int expected_column, bool is_eval, bool is_constructor,
     v8::Handle<v8::StackFrame> frame) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::String::Utf8Value func_name(frame->GetFunctionName());
   v8::String::Utf8Value script_name(frame->GetScriptName());
   if (*script_name == NULL) {
@@ -14694,7 +14689,7 @@
 
 
 v8::Handle<Value> AnalyzeStackInNativeCode(const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   const char* origin = "capture-stack-trace-test";
   const int kOverviewTest = 1;
   const int kDetailedTest = 2;
@@ -14749,7 +14744,7 @@
 // TODO(3074796): Reenable this as a THREADED_TEST once it passes.
 // THREADED_TEST(CaptureStackTrace) {
 TEST(CaptureStackTrace) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::String> origin = v8::String::New("capture-stack-trace-test");
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("AnalyzeStackInNativeCode"),
@@ -14808,8 +14803,8 @@
 
 TEST(CaptureStackTraceForUncaughtException) {
   report_count = 0;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::AddMessageListener(StackTraceForUncaughtExceptionListener);
   v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
 
@@ -14830,8 +14825,8 @@
 
 
 TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::SetCaptureStackTraceForUncaughtExceptions(true,
                                                     1024,
                                                     v8::StackTrace::kDetailed);
@@ -14866,8 +14861,8 @@
 // Test that we only return the stack trace at the site where the exception
 // is first thrown (not where it is rethrown).
 TEST(RethrowStackTrace) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   // We make sure that
   // - the stack trace of the ReferenceError in g() is reported.
   // - the stack trace is not overwritten when e1 is rethrown by t().
@@ -14908,8 +14903,8 @@
 
 // Test that we do not recognize identity for primitive exceptions.
 TEST(RethrowPrimitiveStackTrace) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   // We do not capture stack trace for non Error objects on creation time.
   // Instead, we capture the stack trace on last throw.
   const char* source =
@@ -14942,8 +14937,8 @@
 // Test that the stack trace is captured when the error object is created and
 // not where it is thrown.
 TEST(RethrowExistingStackTrace) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source =
       "var e = new Error();           \n"
       "throw e;                       \n";
@@ -14967,8 +14962,8 @@
 
 // Test that the stack trace is captured where the bogus Error object is thrown.
 TEST(RethrowBogusErrorStackTrace) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source =
       "var e = {__proto__: new Error()} \n"
       "throw e;                         \n";
@@ -14981,7 +14976,7 @@
 
 
 v8::Handle<Value> AnalyzeStackOfEvalWithSourceURL(const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   v8::Handle<v8::StackTrace> stackTrace =
       v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
   CHECK_EQ(5, stackTrace->GetFrameCount());
@@ -14997,7 +14992,7 @@
 
 
 TEST(SourceURLInStackTrace) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("AnalyzeStackOfEvalWithSourceURL"),
              v8::FunctionTemplate::New(AnalyzeStackOfEvalWithSourceURL));
@@ -15021,7 +15016,7 @@
 
 v8::Handle<Value> AnalyzeStackOfInlineScriptWithSourceURL(
     const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   v8::Handle<v8::StackTrace> stackTrace =
       v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
   CHECK_EQ(4, stackTrace->GetFrameCount());
@@ -15037,7 +15032,7 @@
 
 
 TEST(InlineScriptWithSourceURLInStackTrace) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("AnalyzeStackOfInlineScriptWithSourceURL"),
              v8::FunctionTemplate::New(
@@ -15063,7 +15058,7 @@
 
 v8::Handle<Value> AnalyzeStackOfDynamicScriptWithSourceURL(
     const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   v8::Handle<v8::StackTrace> stackTrace =
       v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed);
   CHECK_EQ(4, stackTrace->GetFrameCount());
@@ -15079,7 +15074,7 @@
 
 
 TEST(DynamicWithSourceURLInStackTrace) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->Set(v8_str("AnalyzeStackOfDynamicScriptWithSourceURL"),
              v8::FunctionTemplate::New(
@@ -15103,7 +15098,7 @@
 }
 
 static void CreateGarbageInOldSpace() {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   i::AlwaysAllocateScope always_allocate;
   for (int i = 0; i < 1000; i++) {
     FACTORY->NewFixedArray(1000, i::TENURED);
@@ -15113,8 +15108,8 @@
 // Test that idle notification can be handled and eventually returns true.
 TEST(IdleNotification) {
   const intptr_t MB = 1024 * 1024;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   intptr_t initial_size = HEAP->SizeOfObjects();
   CreateGarbageInOldSpace();
   intptr_t size_with_garbage = HEAP->SizeOfObjects();
@@ -15133,8 +15128,8 @@
 TEST(IdleNotificationWithSmallHint) {
   const intptr_t MB = 1024 * 1024;
   const int IdlePauseInMs = 900;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   intptr_t initial_size = HEAP->SizeOfObjects();
   CreateGarbageInOldSpace();
   intptr_t size_with_garbage = HEAP->SizeOfObjects();
@@ -15153,8 +15148,8 @@
 TEST(IdleNotificationWithLargeHint) {
   const intptr_t MB = 1024 * 1024;
   const int IdlePauseInMs = 900;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   intptr_t initial_size = HEAP->SizeOfObjects();
   CreateGarbageInOldSpace();
   intptr_t size_with_garbage = HEAP->SizeOfObjects();
@@ -15173,8 +15168,8 @@
   const intptr_t MB = 1024 * 1024;
   const int kShortIdlePauseInMs = 100;
   const int kLongIdlePauseInMs = 1000;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   intptr_t initial_size = HEAP->SizeOfObjects();
   // Send idle notification to start a round of incremental GCs.
   v8::V8::IdleNotification(kShortIdlePauseInMs);
@@ -15233,8 +15228,8 @@
   CHECK(v8::SetResourceConstraints(&constraints));
 
   // Execute a script.
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   Local<v8::FunctionTemplate> fun_templ =
       v8::FunctionTemplate::New(GetStackLimitCallback);
   Local<Function> fun = fun_templ->GetFunction();
@@ -15258,7 +15253,7 @@
     CHECK(v8::SetResourceConstraints(&constraints));
 
     // Execute a script.
-    v8::HandleScope scope;
+    v8::HandleScope scope(CcTest::default_isolate());
     LocalContext env;
     Local<v8::FunctionTemplate> fun_templ =
         v8::FunctionTemplate::New(GetStackLimitCallback);
@@ -15276,8 +15271,8 @@
 
 
 THREADED_TEST(GetHeapStatistics) {
-  v8::HandleScope scope;
   LocalContext c1;
+  v8::HandleScope scope(c1->GetIsolate());
   v8::HeapStatistics heap_statistics;
   CHECK_EQ(static_cast<int>(heap_statistics.total_heap_size()), 0);
   CHECK_EQ(static_cast<int>(heap_statistics.used_heap_size()), 0);
@@ -15323,8 +15318,8 @@
 };
 
 TEST(VisitExternalStrings) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const char* string = "Some string";
   uint16_t* two_byte_string = AsciiToTwoByteString(string);
   TestResource* resource[4];
@@ -15389,8 +15384,8 @@
 
 
 THREADED_TEST(QuietSignalingNaNs) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::TryCatch try_catch;
 
   // Special double values.
@@ -15473,7 +15468,7 @@
 
 
 static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   v8::TryCatch tc;
   v8::Handle<v8::String> str(args[0]->ToString());
   USE(str);
@@ -15486,7 +15481,7 @@
 // Test that an exception can be propagated down through a spaghetti
 // stack using ReThrow.
 THREADED_TEST(SpaghettiStackReThrow) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext context;
   context->Global()->Set(
       v8::String::New("s"),
@@ -15514,7 +15509,7 @@
 TEST(Regress528) {
   v8::V8::Initialize();
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Persistent<Context> context;
   v8::Persistent<Context> other_context;
   int gc_count;
@@ -15528,7 +15523,7 @@
   const char* source_simple = "1";
   context = Context::New();
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
 
     context->Enter();
     Local<v8::String> obj = v8::String::New("");
@@ -15553,7 +15548,7 @@
   const char* source_eval = "function f(){eval('1')}; f()";
   context = Context::New();
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
 
     context->Enter();
     CompileRun(source_eval);
@@ -15576,7 +15571,7 @@
   const char* source_exception = "function f(){throw 1;} f()";
   context = Context::New();
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
 
     context->Enter();
     v8::TryCatch try_catch;
@@ -15605,8 +15600,8 @@
 
 
 THREADED_TEST(ScriptOrigin) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
   v8::Handle<v8::String> script = v8::String::New(
       "function f() {}\n\nfunction g() {}");
@@ -15626,8 +15621,8 @@
 }
 
 THREADED_TEST(FunctionGetInferredName) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
   v8::Handle<v8::String> script = v8::String::New(
       "var foo = { bar : { baz : function() {}}}; var f = foo.bar.baz;");
@@ -15638,8 +15633,8 @@
 }
 
 THREADED_TEST(ScriptLineNumber) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
   v8::Handle<v8::String> script = v8::String::New(
       "function f() {}\n\nfunction g() {}");
@@ -15654,8 +15649,8 @@
 
 
 THREADED_TEST(ScriptColumnNumber) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"),
       v8::Integer::New(3), v8::Integer::New(2));
   v8::Handle<v8::String> script = v8::String::New(
@@ -15671,8 +15666,8 @@
 
 
 THREADED_TEST(FunctionGetScriptId) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"),
       v8::Integer::New(3), v8::Integer::New(2));
   v8::Handle<v8::String> scriptSource = v8::String::New(
@@ -15726,7 +15721,7 @@
 
 
 TEST(SetterOnConstructorPrototype) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("x"),
                      GetterWhichReturns42,
@@ -15776,7 +15771,7 @@
 
 
 THREADED_TEST(InterceptorOnConstructorPrototype) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetNamedPropertyHandler(NamedPropertyGetterWhichReturns42,
                                  NamedPropertySetterWhichSetsYOnThisTo23);
@@ -15815,8 +15810,8 @@
                        "};"
                        "C1.prototype = P;";
 
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Local<v8::Script> script;
 
   // Use a simple object as prototype.
@@ -15911,7 +15906,7 @@
 
 THREADED_TEST(AddToJSFunctionResultCache) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   LocalContext context;
 
@@ -15938,9 +15933,8 @@
 
 THREADED_TEST(FillJSFunctionResultCache) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   const char* code =
       "(function() {"
@@ -15960,9 +15954,8 @@
 
 THREADED_TEST(RoundRobinGetFromCache) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   const char* code =
       "(function() {"
@@ -15985,9 +15978,8 @@
 
 THREADED_TEST(ReverseGetFromCache) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   const char* code =
       "(function() {"
@@ -16010,9 +16002,8 @@
 
 THREADED_TEST(TestEviction) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   const char* code =
       "(function() {"
@@ -16028,9 +16019,9 @@
 
 THREADED_TEST(TwoByteStringInAsciiCons) {
   // See Chromium issue 47824.
-  v8::HandleScope scope;
-
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
+
   const char* init_code =
       "var str1 = 'abelspendabel';"
       "var str2 = str1 + str1 + str1;"
@@ -16129,7 +16120,7 @@
   v8::V8::Initialize();
   v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC);
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   // Create an ObjectTemplate for global objects and install access
   // check callbacks that will block access.
@@ -16222,10 +16213,10 @@
 }
 
 TEST(IsolateEnterExitDefault) {
-  v8::HandleScope scope;
-  LocalContext context;
   v8::Isolate* current_isolate = v8::Isolate::GetCurrent();
   CHECK(current_isolate != NULL);  // Default isolate.
+  v8::HandleScope scope(current_isolate);
+  LocalContext context;
   ExpectString("'hello'", "hello");
   current_isolate->Enter();
   ExpectString("'still working'", "still working");
@@ -16243,7 +16234,7 @@
   v8::V8::SetFatalErrorHandler(StoringErrorCallback);
 
   // Run some V8 code to trigger default isolate to become 'current'.
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext context;
   ExpectString("'run some V8'", "run some V8");
 
@@ -16257,7 +16248,7 @@
 }
 
 TEST(RunDefaultAndAnotherIsolate) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext context;
 
   // Enter new isolate.
@@ -16266,7 +16257,7 @@
   isolate->Enter();
   { // Need this block because subsequent Exit() will deallocate Heap,
     // so we need all scope objects to be deconstructed when it happens.
-    v8::HandleScope scope_new;
+    v8::HandleScope scope_new(isolate);
     LocalContext context_new;
 
     // Run something in new isolate.
@@ -16302,7 +16293,7 @@
   v8::Isolate* isolate = v8::Isolate::New();
   CHECK(isolate);
   isolate->Enter();
-  v8::HandleScope scope;
+  v8::HandleScope scope(isolate);
   LocalContext context;
   // Run something in this isolate.
   ExpectTrue("true");
@@ -16322,7 +16313,7 @@
 
   {
     v8::Context::Scope cscope(context1);
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate1);
     // Run something in new isolate.
     CompileRun("var foo = 'isolate 1';");
     ExpectString("function f() { return foo; }; f()", "isolate 1");
@@ -16336,7 +16327,7 @@
     v8::Isolate::Scope iscope(isolate2);
     context2 = v8::Context::New();
     v8::Context::Scope cscope(context2);
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate2);
 
     // Run something in new isolate.
     CompileRun("var foo = 'isolate 2';");
@@ -16345,7 +16336,7 @@
 
   {
     v8::Context::Scope cscope(context1);
-    v8::HandleScope scope;
+    v8::HandleScope scope(isolate1);
     // Now again in isolate 1
     ExpectString("function f() { return foo; }; f()", "isolate 1");
   }
@@ -16357,7 +16348,7 @@
 
   {
     v8::Context::Scope cscope(context_default);
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     // Variables in other isolates should be not available, verify there
     // is an exception.
     ExpectTrue("function f() {"
@@ -16377,13 +16368,13 @@
   {
     v8::Isolate::Scope iscope(isolate2);
     v8::Context::Scope cscope(context2);
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     ExpectString("function f() { return foo; }; f()", "isolate 2");
   }
 
   {
     v8::Context::Scope cscope(context1);
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     ExpectString("function f() { return foo; }; f()", "isolate 1");
   }
 
@@ -16409,14 +16400,14 @@
   // Check that default isolate still runs.
   {
     v8::Context::Scope cscope(context_default);
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     ExpectTrue("function f() { return isDefaultIsolate; }; f()");
   }
 }
 
 static int CalcFibonacci(v8::Isolate* isolate, int limit) {
   v8::Isolate::Scope isolate_scope(isolate);
-  v8::HandleScope scope;
+  v8::HandleScope scope(isolate);
   LocalContext context;
   i::ScopedVector<char> code(1024);
   i::OS::SNPrintF(code, "function fib(n) {"
@@ -16482,7 +16473,7 @@
   Persistent<v8::Context> context;
   {
     v8::Isolate::Scope isolate_scope(isolate);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     context = v8::Context::New();
     v8::Context::Scope context_scope(context);
     Local<Value> v = CompileRun("2");
@@ -16491,7 +16482,7 @@
   }
   {
     v8::Isolate::Scope isolate_scope(isolate);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     context = v8::Context::New();
     v8::Context::Scope context_scope(context);
     Local<Value> v = CompileRun("22");
@@ -16597,8 +16588,8 @@
 
   {
     // Run the code twice in the first context to initialize the call IC.
-    v8::HandleScope scope;
     LocalContext context1;
+    v8::HandleScope scope(context1->GetIsolate());
     ExpectString(code, "a");
     ExpectString(code, "a");
   }
@@ -16606,8 +16597,8 @@
   {
     // Change the String.prototype in the second context and check
     // that the right function gets called.
-    v8::HandleScope scope;
     LocalContext context2;
+    v8::HandleScope scope(context2->GetIsolate());
     CompileRun("String.prototype.charAt = function() { return \"not a\"; }");
     ExpectString(code, "not a");
   }
@@ -16620,8 +16611,8 @@
 
   {
     // Run the code twice in the first context to initialize the call IC.
-    v8::HandleScope scope;
     LocalContext context1;
+    v8::HandleScope scope(context1->GetIsolate());
     ExpectString(code, "42");
     ExpectString(code, "42");
   }
@@ -16629,8 +16620,8 @@
   {
     // Change the Number.prototype in the second context and check
     // that the right function gets called.
-    v8::HandleScope scope;
     LocalContext context2;
+    v8::HandleScope scope(context2->GetIsolate());
     CompileRun("Number.prototype.toString = function() { return \"not 42\"; }");
     ExpectString(code, "not 42");
   }
@@ -16643,8 +16634,8 @@
 
   {
     // Run the code twice in the first context to initialize the call IC.
-    v8::HandleScope scope;
     LocalContext context1;
+    v8::HandleScope scope(context1->GetIsolate());
     ExpectString(code, "true");
     ExpectString(code, "true");
   }
@@ -16652,8 +16643,8 @@
   {
     // Change the Boolean.prototype in the second context and check
     // that the right function gets called.
-    v8::HandleScope scope;
     LocalContext context2;
+    v8::HandleScope scope(context2->GetIsolate());
     CompileRun("Boolean.prototype.toString = function() { return \"\"; }");
     ExpectString(code, "");
   }
@@ -16667,8 +16658,8 @@
   {
     // Run the code twice in the first context to initialize the load
     // IC for a don't delete cell.
-    v8::HandleScope scope;
     LocalContext context1;
+    v8::HandleScope scope(context1->GetIsolate());
     CompileRun("var cell = \"first\";");
     ExpectBoolean("delete cell", false);
     CompileRun(function_code);
@@ -16678,8 +16669,8 @@
 
   {
     // Use a deletable cell in the second context.
-    v8::HandleScope scope;
     LocalContext context2;
+    v8::HandleScope scope(context2->GetIsolate());
     CompileRun("cell = \"second\";");
     CompileRun(function_code);
     ExpectString("readCell()", "second");
@@ -16706,8 +16697,8 @@
 
   // Run the code twice to initialize the load IC for a don't delete
   // cell.
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   CompileRun("var cell = \"value\";");
   ExpectBoolean("delete cell", false);
   CompileRun(function_code);
@@ -16734,8 +16725,8 @@
 
   // Run the code twice to initialize the load IC for a don't delete
   // cell created using the API.
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   context->Global()->Set(v8_str("cell"), v8_str("value"), v8::DontDelete);
   ExpectBoolean("delete cell", false);
   CompileRun(function_code);
@@ -16779,9 +16770,9 @@
 
 
 TEST(PersistentHandleVisitor) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(isolate);
   v8::Persistent<v8::Object> object =
       v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
   CHECK_EQ(0, object.WrapperClassId(isolate));
@@ -16797,9 +16788,9 @@
 
 
 TEST(WrapperClassId) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(isolate);
   v8::Persistent<v8::Object> object =
       v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
   CHECK_EQ(0, object.WrapperClassId(isolate));
@@ -16810,9 +16801,9 @@
 
 
 TEST(PersistentHandleInNewSpaceVisitor) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(isolate);
   v8::Persistent<v8::Object> object1 =
       v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
   CHECK_EQ(0, object1.WrapperClassId(isolate));
@@ -16837,8 +16828,8 @@
 
 
 TEST(RegExp) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   v8::Handle<v8::RegExp> re = v8::RegExp::New(v8_str("foo"), v8::RegExp::kNone);
   CHECK(re->IsRegExp());
@@ -16907,8 +16898,8 @@
 
 
 THREADED_TEST(Equals) {
-  v8::HandleScope handleScope;
   LocalContext localContext;
+  v8::HandleScope handleScope(localContext->GetIsolate());
 
   v8::Handle<v8::Object> globalProxy = localContext->Global();
   v8::Handle<Value> global = globalProxy->GetPrototype();
@@ -16939,8 +16930,8 @@
 
 
 TEST(NamedEnumeratorAndForIn) {
-  v8::HandleScope handle_scope;
   LocalContext context;
+  v8::HandleScope handle_scope(context->GetIsolate());
   v8::Context::Scope context_scope(context.local());
 
   v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
@@ -16954,8 +16945,8 @@
 
 
 TEST(DefinePropertyPostDetach) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   v8::Handle<v8::Object> proxy = context->Global();
   v8::Handle<v8::Function> define_property =
       CompileRun("(function() {"
@@ -16982,7 +16973,7 @@
 
 
 THREADED_TEST(CreationContext) {
-  HandleScope handle_scope;
+  HandleScope handle_scope(v8::Isolate::GetCurrent());
   Persistent<Context> context1 = Context::New();
   InstallContextId(context1, 1);
   Persistent<Context> context2 = Context::New();
@@ -17069,7 +17060,7 @@
 
 
 THREADED_TEST(CreationContextOfJsFunction) {
-  HandleScope handle_scope;
+  HandleScope handle_scope(v8::Isolate::GetCurrent());
   Persistent<Context> context = Context::New();
   InstallContextId(context, 1);
 
@@ -17128,8 +17119,8 @@
 
 
 TEST(HasOwnProperty) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   { // Check normal properties and defined getters.
     Handle<Value> value = CompileRun(
         "function Foo() {"
@@ -17201,7 +17192,7 @@
 
 
 TEST(IndexedInterceptorWithStringProto) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetIndexedPropertyHandler(NULL,
                                    NULL,
@@ -17263,8 +17254,8 @@
 
 
 THREADED_TEST(AllowCodeGenFromStrings) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   // eval and the Function constructor allowed by default.
   CHECK(context->IsCodeGenerationFromStringsAllowed());
@@ -17293,8 +17284,8 @@
 
 
 TEST(SetErrorMessageForCodeGenFromStrings) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   TryCatch try_catch;
 
   Handle<String> message = v8_str("Message") ;
@@ -17316,8 +17307,8 @@
 
 
 THREADED_TEST(CallAPIFunctionOnNonObject) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Handle<FunctionTemplate> templ = v8::FunctionTemplate::New(NonObjectThis);
   Handle<Function> function = templ->GetFunction();
   context->Global()->Set(v8_str("f"), function);
@@ -17328,7 +17319,7 @@
 
 // Regression test for issue 1470.
 THREADED_TEST(ReadOnlyIndexedProperties) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
 
   LocalContext context;
@@ -17349,10 +17340,10 @@
 
 
 THREADED_TEST(Regress1516) {
-  v8::HandleScope scope;
-
   LocalContext context;
-  { v8::HandleScope temp_scope;
+  v8::HandleScope scope(context->GetIsolate());
+
+  { v8::HandleScope temp_scope(context->GetIsolate());
     CompileRun("({'a': 0})");
   }
 
@@ -17393,7 +17384,7 @@
 
 
 THREADED_TEST(Regress93759) {
-  HandleScope scope;
+  HandleScope scope(v8::Isolate::GetCurrent());
 
   // Template for object with security check.
   Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New();
@@ -17484,7 +17475,7 @@
 
 
 THREADED_TEST(Regress125988) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   Handle<FunctionTemplate> intercept = FunctionTemplate::New();
   AddInterceptor(intercept, EmptyInterceptorGetter, EmptyInterceptorSetter);
   LocalContext env;
@@ -17518,7 +17509,7 @@
 
 
 THREADED_TEST(ForeignFunctionReceiver) {
-  HandleScope scope;
+  HandleScope scope(v8::Isolate::GetCurrent());
 
   // Create two contexts with different "id" properties ('i' and 'o').
   // Call a function both from its own context and from a the foreign
@@ -17646,8 +17637,8 @@
 
 
 TEST(CallCompletedCallback) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::FunctionTemplate> recursive_runtime =
       v8::FunctionTemplate::New(RecursiveCall);
   env->Global()->Set(v8_str("recursion"),
@@ -17679,28 +17670,28 @@
 
 
 void CallCompletedCallbackNoException() {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   CompileRun("1+1;");
 }
 
 
 void CallCompletedCallbackException() {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   CompileRun("throw 'second exception';");
 }
 
 
 TEST(CallCompletedCallbackOneException) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::AddCallCompletedCallback(CallCompletedCallbackNoException);
   CompileRun("throw 'exception';");
 }
 
 
 TEST(CallCompletedCallbackTwoExceptions) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::V8::AddCallCompletedCallback(CallCompletedCallbackException);
   CompileRun("throw 'first exception';");
 }
@@ -17748,8 +17739,8 @@
     i::FLAG_test_secondary_stub_cache = true;
   }
   i::FLAG_crankshaft = false;
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   int initial_probes = probes_counter;
   int initial_misses = misses_counter;
   int initial_updates = updates_counter;
@@ -17782,9 +17773,9 @@
 
 
 TEST(StaticGetters) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::HandleScope scope(isolate);
   i::Handle<i::Object> undefined_value = FACTORY->undefined_value();
   CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
   CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
@@ -17844,9 +17835,9 @@
 
 
 TEST(StringEmpty) {
-  v8::HandleScope scope;
   LocalContext context;
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::HandleScope scope(isolate);
   i::Handle<i::Object> empty_string = FACTORY->empty_string();
   CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
   CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
@@ -17947,8 +17938,8 @@
 
 THREADED_TEST(InstanceCheckOnInstanceAccessor) {
   v8::internal::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   Local<FunctionTemplate> templ = FunctionTemplate::New();
   Local<ObjectTemplate> inst = templ->InstanceTemplate();
@@ -17975,8 +17966,8 @@
 
 THREADED_TEST(InstanceCheckOnInstanceAccessorWithInterceptor) {
   v8::internal::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   Local<FunctionTemplate> templ = FunctionTemplate::New();
   Local<ObjectTemplate> inst = templ->InstanceTemplate();
@@ -18004,8 +17995,8 @@
 
 THREADED_TEST(InstanceCheckOnPrototypeAccessor) {
   v8::internal::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   Local<FunctionTemplate> templ = FunctionTemplate::New();
   Local<ObjectTemplate> proto = templ->PrototypeTemplate();
@@ -18039,8 +18030,8 @@
 
 
 TEST(TryFinallyMessage) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   {
     // Test that the original error message is not lost if there is a
     // recursive call into Javascript is done in the finally block, e.g. to
@@ -18131,7 +18122,7 @@
 THREADED_TEST(Regress137002a) {
   i::FLAG_allow_natives_syntax = true;
   i::FLAG_compilation_cache = false;
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   for (int i = 0; i < 16; i++) {
     Helper137002(i & 8, i & 4, i & 2, i & 1);
   }
@@ -18140,8 +18131,8 @@
 
 THREADED_TEST(Regress137002b) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("foo"),
                      GetterWhichReturns42,
@@ -18208,8 +18199,8 @@
 
 THREADED_TEST(Regress142088) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   templ->SetAccessor(v8_str("foo"),
                      GetterWhichReturns42,
@@ -18225,8 +18216,8 @@
 
 THREADED_TEST(Regress137496) {
   i::FLAG_expose_gc = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
 
   // Compile a try-finally clause where the finally block causes a GC
   // while there still is a message pending for external reporting.
@@ -18238,8 +18229,8 @@
 
 
 THREADED_TEST(Regress149912) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Handle<FunctionTemplate> templ = FunctionTemplate::New();
   AddInterceptor(templ, EmptyInterceptorGetter, EmptyInterceptorSetter);
   context->Global()->Set(v8_str("Bug"), templ->GetFunction());
@@ -18248,8 +18239,8 @@
 
 
 THREADED_TEST(Regress157124) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<ObjectTemplate> templ = ObjectTemplate::New();
   Local<Object> obj = templ->NewInstance();
   obj->GetIdentityHash();
@@ -18259,8 +18250,8 @@
 
 THREADED_TEST(Regress2535) {
   i::FLAG_harmony_collections = true;
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Local<Value> set_value = CompileRun("new Set();");
   Local<Object> set_object(Object::Cast(*set_value));
   CHECK_EQ(0, set_object->InternalFieldCount());
diff --git a/test/cctest/test-assembler-arm.cc b/test/cctest/test-assembler-arm.cc
index cfbdb12..5cb4ab3 100644
--- a/test/cctest/test-assembler-arm.cc
+++ b/test/cctest/test-assembler-arm.cc
@@ -57,9 +57,9 @@
 
 TEST(0) {
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
 
   __ add(r0, r0, Operand(r1));
@@ -84,9 +84,9 @@
 
 TEST(1) {
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
   Label L, C;
 
@@ -122,9 +122,9 @@
 
 TEST(2) {
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
   Label L, C;
 
@@ -169,7 +169,8 @@
 
 TEST(3) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     int i;
@@ -178,7 +179,6 @@
   } T;
   T t;
 
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
   Label L, C;
 
@@ -225,7 +225,8 @@
 TEST(4) {
   // Test the VFP floating point instructions.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -246,7 +247,6 @@
 
   // Create a function that accepts &t, and loads, manipulates, and stores
   // the doubles and floats.
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
   Label L, C;
 
@@ -364,9 +364,9 @@
 TEST(5) {
   // Test the ARMv7 bitfield instructions.
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(ARMv7)) {
@@ -401,9 +401,9 @@
 TEST(6) {
   // Test saturating instructions.
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(ARMv7)) {
@@ -445,9 +445,9 @@
                              int expected,
                              bool expected_exception = false) {
   InitializeVM();
-  v8::HandleScope scope;
-
   Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(VFP3)) {
@@ -623,7 +623,8 @@
 TEST(8) {
   // Test VFP multi load/store with ia_w.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -651,7 +652,6 @@
 
   // Create a function that uses vldm/vstm to move some double and
   // single precision values around in memory.
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(VFP2)) {
@@ -735,7 +735,8 @@
 TEST(9) {
   // Test VFP multi load/store with ia.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -763,7 +764,6 @@
 
   // Create a function that uses vldm/vstm to move some double and
   // single precision values around in memory.
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(VFP2)) {
@@ -851,7 +851,8 @@
 TEST(10) {
   // Test VFP multi load/store with db_w.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -879,7 +880,6 @@
 
   // Create a function that uses vldm/vstm to move some double and
   // single precision values around in memory.
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(VFP2)) {
@@ -963,7 +963,8 @@
 TEST(11) {
   // Test instructions using the carry flag.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     int32_t a;
@@ -976,7 +977,6 @@
   i.a = 0xabcd0001;
   i.b = 0xabcd0000;
 
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
 
   // Test HeapObject untagging.
@@ -1029,9 +1029,10 @@
 TEST(12) {
   // Test chaining of label usages within instructions (issue 1644).
   InitializeVM();
-  v8::HandleScope scope;
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
+  Assembler assm(isolate, NULL, 0);
   Label target;
   __ b(eq, &target);
   __ b(ne, &target);
@@ -1043,7 +1044,8 @@
 TEST(13) {
   // Test VFP instructions using registers d16-d31.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   if (!CpuFeatures::IsSupported(VFP32DREGS)) {
     return;
@@ -1064,7 +1066,6 @@
 
   // Create a function that accepts &t, and loads, manipulates, and stores
   // the doubles and floats.
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, NULL, 0);
   Label L, C;
 
diff --git a/test/cctest/test-assembler-ia32.cc b/test/cctest/test-assembler-ia32.cc
index e92e48f..6176285 100644
--- a/test/cctest/test-assembler-ia32.cc
+++ b/test/cctest/test-assembler-ia32.cc
@@ -58,10 +58,10 @@
 
 TEST(AssemblerIa320) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
 
   __ mov(eax, Operand(esp, 4));
@@ -87,10 +87,10 @@
 
 TEST(AssemblerIa321) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
   Label L, C;
 
@@ -126,10 +126,10 @@
 
 TEST(AssemblerIa322) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
   Label L, C;
 
@@ -173,10 +173,10 @@
   InitializeVM();
   if (!CpuFeatures::IsSupported(SSE2)) return;
 
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
 
   CHECK(CpuFeatures::IsSupported(SSE2));
@@ -209,10 +209,10 @@
   InitializeVM();
   if (!CpuFeatures::IsSupported(SSE2)) return;
 
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
 
   CHECK(CpuFeatures::IsSupported(SSE2));
@@ -241,10 +241,10 @@
 static int baz = 42;
 TEST(AssemblerIa325) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
 
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
 
   __ mov(eax, Operand(reinterpret_cast<intptr_t>(&baz), RelocInfo::NONE32));
@@ -268,9 +268,9 @@
   InitializeVM();
   if (!CpuFeatures::IsSupported(SSE2)) return;
 
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
 
   CpuFeatureScope fscope(&assm, SSE2);
@@ -314,9 +314,9 @@
   InitializeVM();
   if (!CpuFeatures::IsSupported(SSE2)) return;
 
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof buffer);
   CpuFeatureScope fscope(&assm, SSE2);
   __ mov(eax, Operand(esp, 4));
@@ -349,9 +349,9 @@
 
 TEST(AssemblerIa329) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   v8::internal::byte buffer[256];
-  Isolate* isolate = Isolate::Current();
   MacroAssembler assm(isolate, buffer, sizeof buffer);
   enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 };
   Label equal_l, less_l, greater_l, nan_l;
@@ -405,8 +405,8 @@
 TEST(AssemblerIa3210) {
   // Test chaining of label usages within instructions (issue 1644).
   InitializeVM();
-  v8::HandleScope scope;
-  Isolate* isolate = Isolate::Current();
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   Assembler assm(isolate, NULL, 0);
 
   Label target;
@@ -419,9 +419,9 @@
 
 TEST(AssemblerMultiByteNop) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   v8::internal::byte buffer[1024];
-  Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof(buffer));
   __ push(ebx);
   __ push(ecx);
diff --git a/test/cctest/test-assembler-mips.cc b/test/cctest/test-assembler-mips.cc
index b6d16c3..1e4e9e2 100644
--- a/test/cctest/test-assembler-mips.cc
+++ b/test/cctest/test-assembler-mips.cc
@@ -62,9 +62,10 @@
 
 TEST(MIPS0) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   // Addition.
   __ addu(v0, a0, a1);
@@ -87,9 +88,10 @@
 
 TEST(MIPS1) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
   Label L, C;
 
   __ mov(a1, a0);
@@ -125,9 +127,10 @@
 
 TEST(MIPS2) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   Label exit, error;
 
@@ -266,7 +269,8 @@
 TEST(MIPS3) {
   // Test floating point instructions.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -283,7 +287,7 @@
 
   // Create a function that accepts &t, and loads, manipulates, and stores
   // the doubles t.a ... t.f.
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
   Label L, C;
 
   if (CpuFeatures::IsSupported(FPU)) {
@@ -357,7 +361,8 @@
 TEST(MIPS4) {
   // Test moves between floating point and integer registers.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -366,7 +371,7 @@
   } T;
   T t;
 
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Assembler assm(isolate, NULL, 0);
   Label L, C;
 
   if (CpuFeatures::IsSupported(FPU)) {
@@ -417,7 +422,8 @@
 TEST(MIPS5) {
   // Test conversions between doubles and integers.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -427,7 +433,7 @@
   } T;
   T t;
 
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Assembler assm(isolate, NULL, 0);
   Label L, C;
 
   if (CpuFeatures::IsSupported(FPU)) {
@@ -488,7 +494,8 @@
 TEST(MIPS6) {
   // Test simple memory loads and stores.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     uint32_t ui;
@@ -502,7 +509,7 @@
   } T;
   T t;
 
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Assembler assm(isolate, NULL, 0);
   Label L, C;
 
   // Basic word load/store.
@@ -560,7 +567,8 @@
 TEST(MIPS7) {
   // Test floating point compare and branch instructions.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -575,7 +583,7 @@
 
   // Create a function that accepts &t, and loads, manipulates, and stores
   // the doubles t.a ... t.f.
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
   Label neither_is_nan, less_than, outa_here;
 
   if (CpuFeatures::IsSupported(FPU)) {
@@ -641,7 +649,8 @@
 TEST(MIPS8) {
   // Test ROTR and ROTRV instructions.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     int32_t input;
@@ -662,7 +671,7 @@
   } T;
   T t;
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   // Basic word load.
   __ lw(t0, MemOperand(a0, OFFSET_OF(T, input)) );
@@ -745,9 +754,10 @@
 TEST(MIPS9) {
   // Test BRANCH improvements.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
   Label exit, exit2, exit3;
 
   __ Branch(&exit, ge, a0, Operand(0x00000000));
@@ -774,7 +784,8 @@
   // Test conversions between doubles and long integers.
   // Test hos the long ints map to FP regs pairs.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double a;
@@ -788,7 +799,7 @@
   } T;
   T t;
 
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Assembler assm(isolate, NULL, 0);
   Label L, C;
 
   if (CpuFeatures::IsSupported(FPU) && kArchVariant == kMips32r2) {
@@ -848,7 +859,8 @@
 TEST(MIPS11) {
   // Test LWL, LWR, SWL and SWR instructions.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     int32_t reg_init;
@@ -872,7 +884,7 @@
   } T;
   T t;
 
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Assembler assm(isolate, NULL, 0);
 
   // Test all combinations of LWL and vAddr.
   __ lw(t0, MemOperand(a0, OFFSET_OF(T, reg_init)) );
@@ -991,7 +1003,8 @@
 
 TEST(MIPS12) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
       int32_t  x;
@@ -1003,7 +1016,7 @@
   } T;
   T t;
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   __ mov(t6, fp);  // Save frame pointer.
   __ mov(fp, a0);  // Access struct T by fp.
@@ -1082,7 +1095,8 @@
 TEST(MIPS13) {
   // Test Cvt_d_uw and Trunc_uw_d macros.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
   typedef struct {
     double cvt_big_out;
@@ -1094,7 +1108,7 @@
   } T;
   T t;
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(FPU)) {
     CpuFeatureScope scope(&assm, FPU);
@@ -1144,7 +1158,8 @@
 TEST(MIPS14) {
   // Test round, floor, ceil, trunc, cvt.
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
 
 #define ROUND_STRUCT_ELEMENT(x) \
   int32_t x##_up_out; \
@@ -1177,7 +1192,7 @@
 
 #undef ROUND_STRUCT_ELEMENT
 
-  MacroAssembler assm(Isolate::Current(), NULL, 0);
+  MacroAssembler assm(isolate, NULL, 0);
 
   if (CpuFeatures::IsSupported(FPU)) {
     CpuFeatureScope scope(&assm, FPU);
@@ -1280,8 +1295,9 @@
 TEST(MIPS15) {
   // Test chaining of label usages within instructions (issue 1644).
   InitializeVM();
-  v8::HandleScope scope;
-  Assembler assm(Isolate::Current(), NULL, 0);
+  Isolate* isolate = Isolate::Current();
+  HandleScope scope(isolate);
+  Assembler assm(isolate, NULL, 0);
 
   Label target;
   __ beq(v0, v1, &target);
diff --git a/test/cctest/test-assembler-x64.cc b/test/cctest/test-assembler-x64.cc
index af06b01..d2ea771 100644
--- a/test/cctest/test-assembler-x64.cc
+++ b/test/cctest/test-assembler-x64.cc
@@ -361,7 +361,8 @@
 
 TEST(AssemblerX64LabelChaining) {
   // Test chaining of label usages within instructions (issue 1644).
-  v8::HandleScope scope;
+  InitializeVM();
+  v8::HandleScope scope(env->GetIsolate());
   Assembler assm(Isolate::Current(), NULL, 0);
 
   Label target;
@@ -374,7 +375,7 @@
 
 TEST(AssemblerMultiByteNop) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::internal::byte buffer[1024];
   Isolate* isolate = Isolate::Current();
   Assembler assm(isolate, buffer, sizeof(buffer));
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index f6632d4..6c100b0 100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -67,7 +67,7 @@
 v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) {
   for (int i = 0; i < args.Length(); i++) {
     if (i != 0) printf(" ");
-    v8::HandleScope scope;
+    v8::HandleScope scope(args.GetIsolate());
     v8::String::Utf8Value str(args[i]);
     if (*str == NULL) return v8::Undefined();
     printf("%s", *str);
@@ -83,12 +83,10 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
     const char* extensions[] = { "v8/print", "v8/gc" };
     v8::ExtensionConfiguration config(2, extensions);
     env = v8::Context::New(&config);
   }
-  v8::HandleScope scope;
   env->Enter();
 }
 
@@ -145,7 +143,7 @@
 
 TEST(Inc) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(4.0, Inc(3));
 }
 
@@ -166,7 +164,7 @@
 
 TEST(Add) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(5.0, Add(2, 3));
 }
 
@@ -186,7 +184,7 @@
 
 TEST(Abs) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(3.0, Abs(-3));
 }
 
@@ -207,14 +205,14 @@
 
 TEST(Sum) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(5050.0, Sum(100));
 }
 
 
 TEST(Print) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "for (n = 0; n < 100; ++n) print(n, 1, 2);";
   Handle<JSFunction> fun = Compile(source);
   if (fun.is_null()) return;
@@ -229,7 +227,7 @@
 // tests all the functionality I have added to the compiler today
 TEST(Stuff) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source =
     "r = 0;\n"
     "a = new Object;\n"
@@ -261,7 +259,7 @@
 
 TEST(UncaughtThrow) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* source = "throw 42;";
   Handle<JSFunction> fun = Compile(source);
@@ -283,7 +281,7 @@
 //   |   C-to-JS     |
 TEST(C2JSFrames) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* source = "function foo(a) { gc(), print(a); }";
 
@@ -320,7 +318,7 @@
 // source resulted in crash.
 TEST(Regression236) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   Handle<Script> script = FACTORY->NewScript(FACTORY->empty_string());
   script->set_source(HEAP->undefined_value());
@@ -332,7 +330,7 @@
 
 TEST(GetScriptLineNumber) {
   LocalContext env;
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test"));
   const char function_f[] = "function f() {}";
   const int max_rows = 1000;
@@ -362,7 +360,7 @@
   if (!FLAG_cache_optimized_code) return;
   FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   for (int i = 0; i < 10; i++) {
     LocalContext env;
     env->Global()->Set(v8::String::New("x"), v8::Integer::New(i));
@@ -425,8 +423,8 @@
 
 
 TEST(SplitConstantsInFullCompiler) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("function f() { a = 12345678 }; f();");
   CheckCodeForUnsafeLiteral(GetJSFunction(env->Global(), "f"));
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc
index 114a8e7..2236f30 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -55,7 +55,7 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) env = v8::Context::New();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   env->Enter();
 }
 
@@ -326,8 +326,8 @@
 
 
 TEST(DeleteCpuProfile) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
   v8::Local<v8::String> name1 = v8::String::New("1");
@@ -372,8 +372,8 @@
 
 
 TEST(DeleteCpuProfileDifferentTokens) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK_EQ(0, v8::CpuProfiler::GetProfilesCount());
   v8::Local<v8::String> name1 = v8::String::New("1");
diff --git a/test/cctest/test-date.cc b/test/cctest/test-date.cc
index 903a63a..0152bb7 100644
--- a/test/cctest/test-date.cc
+++ b/test/cctest/test-date.cc
@@ -119,8 +119,8 @@
 
 TEST(DaylightSavingsTime) {
   LocalContext context;
-  v8::HandleScope scope;
-  Isolate* isolate = Isolate::Current();
+  v8::Isolate* isolate = context->GetIsolate();
+  v8::HandleScope scope(isolate);
   DateCacheMock::Rule rules[] = {
     {0, 2, 0, 10, 0, 3600},  // DST from March to November in any year.
     {2010, 2, 0, 7, 20, 3600},  // DST from March to August 20 in 2010.
@@ -133,7 +133,7 @@
   DateCacheMock* date_cache =
     new DateCacheMock(local_offset_ms, rules, ARRAY_SIZE(rules));
 
-  isolate->set_date_cache(date_cache);
+  reinterpret_cast<Isolate*>(isolate)->set_date_cache(date_cache);
 
   int64_t start_of_2010 = TimeFromYearMonthDay(date_cache, 2010, 0, 1);
   int64_t start_of_2011 = TimeFromYearMonthDay(date_cache, 2011, 0, 1);
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index 8d37440..aa6f153 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -1044,8 +1044,8 @@
 TEST(DebugStub) {
   using ::v8::internal::Builtins;
   using ::v8::internal::Isolate;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CheckDebugBreakFunction(&env,
                           "function f1(){}", "f1",
@@ -1117,8 +1117,8 @@
 // Test that the debug info in the VM is in sync with the functions being
 // debugged.
 TEST(DebugInfo) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   // Create a couple of functions for the test.
   v8::Local<v8::Function> foo =
       CompileFunction(&env, "function foo(){}", "foo");
@@ -1154,8 +1154,8 @@
 // Test that a break point can be set at an IC store location.
 TEST(BreakPointICStore) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
@@ -1187,8 +1187,8 @@
 // Test that a break point can be set at an IC load location.
 TEST(BreakPointICLoad) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
   v8::Script::Compile(v8::String::New("bar=1"))->Run();
@@ -1220,8 +1220,8 @@
 // Test that a break point can be set at an IC call location.
 TEST(BreakPointICCall) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
   v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
@@ -1253,8 +1253,8 @@
 // Test that a break point can be set at an IC call location and survive a GC.
 TEST(BreakPointICCallWithGC) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
                                    v8::Undefined());
   v8::Script::Compile(v8::String::New("function bar(){return 1;}"))->Run();
@@ -1286,8 +1286,8 @@
 // Test that a break point can be set at an IC call location and survive a GC.
 TEST(BreakPointConstructCallWithGC) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
                                    v8::Undefined());
   v8::Script::Compile(v8::String::New("function bar(){ this.x = 1;}"))->Run();
@@ -1320,8 +1320,8 @@
 // Test that a break point can be set at a return store location.
 TEST(BreakPointReturn) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a functions for checking the source line and column when hitting
   // a break point.
@@ -1378,8 +1378,8 @@
 // Test GC during break point processing.
 TEST(GCDuringBreakPointProcessing) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage,
                                    v8::Undefined());
@@ -1442,8 +1442,8 @@
 // Test that a break point can be set at a return store location.
 TEST(BreakPointSurviveGC) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
@@ -1500,8 +1500,8 @@
 // Test that break points can be set using the global Debug object.
 TEST(BreakPointThroughJavaScript) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1556,8 +1556,8 @@
 // global Debug object.
 TEST(ScriptBreakPointByNameThroughJavaScript) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1660,8 +1660,8 @@
 
 TEST(ScriptBreakPointByIdThroughJavaScript) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1769,8 +1769,8 @@
 // Test conditional script break points.
 TEST(EnableDisableScriptBreakPoint) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1826,8 +1826,8 @@
 // Test conditional script break points.
 TEST(ConditionalScriptBreakPoint) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1888,8 +1888,8 @@
 // Test ignore count on script break points.
 TEST(ScriptBreakPointIgnoreCount) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -1943,8 +1943,8 @@
 // Test that script break points survive when a script is reloaded.
 TEST(ScriptBreakPointReload) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -2002,8 +2002,8 @@
 // Test when several scripts has the same script data
 TEST(ScriptBreakPointMultiple) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -2068,8 +2068,8 @@
 // Test the script origin which has both name and line offset.
 TEST(ScriptBreakPointLineOffset) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -2123,8 +2123,8 @@
 
 // Test script break points set on lines.
 TEST(ScriptBreakPointLine) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create a function for checking the function when hitting a break point.
@@ -2229,8 +2229,8 @@
 
 // Test top level script break points set on lines.
 TEST(ScriptBreakPointLineTopLevel) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -2243,7 +2243,7 @@
     "a = 2;                     // line 3\n");
   v8::Local<v8::Function> f;
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     v8::Script::Compile(script, v8::String::New("test.html"))->Run();
   }
   f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
@@ -2275,8 +2275,8 @@
 // Test that it is possible to add and remove break points in a top level
 // function which has no references but has not been collected yet.
 TEST(ScriptBreakPointTopLevelCrash) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
@@ -2290,7 +2290,7 @@
 
   int sbp1 = SetScriptBreakPointByNameFromJS("test.html", 3, -1);
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     break_point_hit_count = 0;
     v8::Script::Compile(script_source, v8::String::New("test.html"))->Run();
     CHECK_EQ(1, break_point_hit_count);
@@ -2308,8 +2308,8 @@
 // Test that it is possible to remove the last break point for a function
 // inside the break handling of that break point.
 TEST(RemoveBreakPointInBreak) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Local<v8::Function> foo =
       CompileFunction(&env, "function foo(){a=1;}", "foo");
@@ -2334,8 +2334,8 @@
 // Test that the debugger statement causes a break.
 TEST(DebuggerStatement) {
   break_point_hit_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
   v8::Script::Compile(v8::String::New("function bar(){debugger}"))->Run();
@@ -2362,8 +2362,8 @@
 // Test setting a breakpoint on the debugger statement.
 TEST(DebuggerStatementBreakpoint) {
     break_point_hit_count = 0;
-    v8::HandleScope scope;
     DebugLocalContext env;
+    v8::HandleScope scope(env->GetIsolate());
     v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                      v8::Undefined());
     v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run();
@@ -2389,8 +2389,8 @@
 // Test that the evaluation of expressions when a break point is hit generates
 // the correct results.
 TEST(DebugEvaluate) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create a function for checking the evaluation when hitting a break point.
@@ -2511,8 +2511,8 @@
 // Test that the conditional breakpoints work event if code generation from
 // strings is prohibited in the debugee context.
 TEST(ConditionalBreakpointWithCodeGenerationDisallowed) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener2(CheckDebugEvent);
@@ -2543,7 +2543,7 @@
 static void CheckDebugEval(const v8::Debug::EventDetails& eventDetails) {
   if (eventDetails.GetEvent() == v8::Break) {
     ++debugEventCount;
-    v8::HandleScope handleScope;
+    v8::HandleScope handleScope(v8::Isolate::GetCurrent());
 
     v8::Handle<v8::Value> args[] = { eventDetails.GetExecutionState() };
     CHECK(checkGlobalEvalFunction->Call(
@@ -2557,8 +2557,8 @@
 // the correct results in case code generation from strings is disallowed in the
 // debugee context.
 TEST(DebugEvaluateWithCodeGenerationDisallowed) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Debug::SetDebugEventListener2(CheckDebugEval);
@@ -2699,8 +2699,8 @@
 TEST(DebugEvaluateWithoutStack) {
   v8::Debug::SetMessageHandler(DebugProcessDebugMessagesHandler);
 
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* source =
       "var v1 = 'Pinguin';\n function getAnimal() { return 'Capy' + 'bara'; }";
@@ -2759,8 +2759,8 @@
 
 // Simple test of the stepping mechanism using only store ICs.
 TEST(DebugStepLinear) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for testing stepping.
   v8::Local<v8::Function> foo = CompileFunction(&env,
@@ -2802,8 +2802,8 @@
 
 // Test of the stepping mechanism for keyed load in a loop.
 TEST(DebugStepKeyedLoadLoop) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -2850,8 +2850,8 @@
 
 // Test of the stepping mechanism for keyed store in a loop.
 TEST(DebugStepKeyedStoreLoop) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -2897,8 +2897,8 @@
 
 // Test of the stepping mechanism for named load in a loop.
 TEST(DebugStepNamedLoadLoop) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -2940,8 +2940,8 @@
 
 
 static void DoDebugStepNamedStoreLoop(int expected) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -2982,8 +2982,8 @@
 
 // Test the stepping mechanism with different ICs.
 TEST(DebugStepLinearMixedICs) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3028,8 +3028,8 @@
 
 
 TEST(DebugStepDeclarations) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3061,8 +3061,8 @@
 
 
 TEST(DebugStepLocals) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3094,8 +3094,8 @@
 
 
 TEST(DebugStepIf) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3137,8 +3137,8 @@
 
 
 TEST(DebugStepSwitch) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3193,8 +3193,8 @@
 
 
 TEST(DebugStepWhile) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3233,8 +3233,8 @@
 
 
 TEST(DebugStepDoWhile) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3273,8 +3273,8 @@
 
 
 TEST(DebugStepFor) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3314,8 +3314,8 @@
 
 
 TEST(DebugStepForContinue) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3365,8 +3365,8 @@
 
 
 TEST(DebugStepForBreak) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3417,8 +3417,8 @@
 
 
 TEST(DebugStepForIn) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3465,8 +3465,8 @@
 
 
 TEST(DebugStepWith) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3496,8 +3496,8 @@
 
 
 TEST(DebugConditional) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which steps and counts.
   v8::Debug::SetDebugEventListener(DebugEventStep);
@@ -3532,8 +3532,8 @@
 
 
 TEST(StepInOutSimple) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for checking the function when hitting a break point.
   frame_function_name = CompileFunction(&env,
@@ -3583,8 +3583,8 @@
 
 
 TEST(StepInOutTree) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for checking the function when hitting a break point.
   frame_function_name = CompileFunction(&env,
@@ -3635,8 +3635,8 @@
 
 
 TEST(StepInOutBranch) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for checking the function when hitting a break point.
   frame_function_name = CompileFunction(&env,
@@ -3671,8 +3671,8 @@
 
 // Test that step in does not step into native functions.
 TEST(DebugStepNatives) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for testing stepping.
   v8::Local<v8::Function> foo = CompileFunction(
@@ -3709,8 +3709,8 @@
 
 // Test that step in works with function.apply.
 TEST(DebugStepFunctionApply) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for testing stepping.
   v8::Local<v8::Function> foo = CompileFunction(
@@ -3748,8 +3748,8 @@
 
 // Test that step in works with function.call.
 TEST(DebugStepFunctionCall) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for testing stepping.
   v8::Local<v8::Function> foo = CompileFunction(
@@ -3799,8 +3799,8 @@
 
 // Tests that breakpoint will be hit if it's set in script.
 TEST(PauseInScript) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Register a debug event listener which counts.
@@ -3835,8 +3835,8 @@
 // check that uncaught exceptions are still returned even if there is a break
 // for them.
 TEST(BreakOnException) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::internal::Isolate::Current()->TraceException(false);
@@ -3979,8 +3979,8 @@
 // v8::Script::Compile there is no JavaScript stack whereas when compiling using
 // eval there are JavaScript frames.
 TEST(BreakOnCompileException) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // For this test, we want to break on uncaught exceptions:
   ChangeBreakOnException(false, true);
@@ -4033,8 +4033,8 @@
 
 
 TEST(StepWithException) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // For this test, we want to break on uncaught exceptions:
   ChangeBreakOnException(false, true);
@@ -4126,8 +4126,8 @@
 #ifdef VERIFY_HEAP
   i::FLAG_verify_heap = true;
 #endif
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which sets the break flag and counts.
   v8::Debug::SetDebugEventListener(DebugEventBreak);
@@ -4178,8 +4178,8 @@
 // Test to ensure that JavaScript code keeps running while the debug break
 // through the stack limit flag is set but breaks are disabled.
 TEST(DisableBreak) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which sets the break flag and counts.
   v8::Debug::SetDebugEventListener(DebugEventCounter);
@@ -4219,7 +4219,7 @@
 // http://crbug.com/28933
 // Test that debug break is disabled when bootstrapper is active.
 TEST(NoBreakWhenBootstrapping) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   // Register a debug event listener which sets the break flag and counts.
   v8::Debug::SetDebugEventListener(DebugEventCounter);
@@ -4287,8 +4287,8 @@
 
 TEST(InterceptorPropertyMirror) {
   // Create a V8 environment with debug access.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create object with named interceptor.
@@ -4418,8 +4418,8 @@
 
 TEST(HiddenPrototypePropertyMirror) {
   // Create a V8 environment with debug access.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Handle<v8::FunctionTemplate> t0 = v8::FunctionTemplate::New();
@@ -4519,8 +4519,8 @@
 
 TEST(NativeGetterPropertyMirror) {
   // Create a V8 environment with debug access.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Handle<v8::String> name = v8::String::New("x");
@@ -4556,8 +4556,8 @@
 
 TEST(NativeGetterThrowingErrorPropertyMirror) {
   // Create a V8 environment with debug access.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   v8::Handle<v8::String> name = v8::String::New("x");
@@ -4591,8 +4591,8 @@
 // See http://crbug.com/26491
 TEST(NoHiddenProperties) {
   // Create a V8 environment with debug access.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create an object in the global scope.
@@ -4938,8 +4938,8 @@
   MessageQueueDebuggerThread message_queue_debugger_thread;
 
   // Create a V8 environment
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   message_queue_barriers.Initialize();
   v8::Debug::SetMessageHandler(MessageHandler);
   message_queue_debugger_thread.Start();
@@ -5030,8 +5030,8 @@
 // Tests that all client data passed to the debugger are sent to the handler.
 TEST(SendClientDataToHandler) {
   // Create a V8 environment
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   TestClientData::ResetCounters();
   handled_client_data_instances_count = 0;
   v8::Debug::SetMessageHandler2(MessageHandlerCountingClientData);
@@ -5136,8 +5136,8 @@
       "foo();\n";
 
   v8::V8::Initialize();
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetMessageHandler2(&ThreadedMessageHandler);
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->Set(v8::String::New("ThreadedAtBarrier1"),
@@ -5249,8 +5249,8 @@
     "cat(19);\n";
 
   v8::V8::Initialize();
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetMessageHandler2(&BreakpointsMessageHandler);
 
   CompileRun(source_1);
@@ -5508,7 +5508,7 @@
 TEST(CallFunctionInDebugger) {
   // Create and enter a context with the functions CheckFrameCount,
   // CheckSourceLine and CheckDataParameter installed.
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->Set(v8::String::New("CheckFrameCount"),
                        v8::FunctionTemplate::New(CheckFrameCount));
@@ -5604,7 +5604,7 @@
   v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
                                    v8::Undefined());
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     // Create a couple of functions for the test.
     v8::Local<v8::Function> foo =
         CompileFunction(&env, "function foo(){x=1}", "foo");
@@ -5634,7 +5634,7 @@
   break_point_hit_count = 0;
   v8::Debug::SetMessageHandler2(MessageHandlerBreakPointHitCount);
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
 
     // Get the test functions again.
     v8::Local<v8::Function> foo(v8::Local<v8::Function>::Cast(
@@ -5687,8 +5687,8 @@
 
 // Test clearing the debug message handler.
 TEST(DebuggerClearMessageHandler) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Check debugger is unloaded before it is used.
   CheckDebuggerUnloaded();
@@ -5730,8 +5730,8 @@
 
 // Test clearing the debug message handler while processing a debug event.
 TEST(DebuggerClearMessageHandlerWhileActive) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Check debugger is unloaded before it is used.
   CheckDebuggerUnloaded();
@@ -5794,8 +5794,8 @@
   const char* source_2 = "cat(17);\n";
 
   v8::V8::Initialize();
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Set up message and host dispatch handlers.
   v8::Debug::SetMessageHandler2(HostDispatchMessageHandler);
@@ -5882,8 +5882,8 @@
 
 void DebugMessageDispatchV8Thread::Run() {
   v8::V8::Initialize();
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Set up debug message dispatch handler.
   v8::Debug::SetDebugMessageDispatchHandler(DebugMessageHandler);
@@ -6109,8 +6109,8 @@
 
 
 TEST(DebugGetLoadedScripts) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   EmptyExternalStringResource source_ext_str;
@@ -6142,8 +6142,8 @@
 
 // Test script break points set on lines.
 TEST(ScriptNameAndData) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create functions for retrieving script name and data for the function on
@@ -6242,7 +6242,7 @@
 // Checks that this data is set correctly and that when the debug message
 // handler is called the expected context is the one active.
 TEST(ContextData) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 
   v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
 
@@ -6318,8 +6318,8 @@
 
 // Test that a debug break can be scheduled while in a message handler.
 TEST(DebugBreakInMessageHandler) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Debug::SetMessageHandler2(DebugBreakMessageHandler);
 
@@ -6379,8 +6379,8 @@
 
 TEST(RegExpDebugBreak) {
   // This test only applies to native regexps.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for checking the function when hitting a break point.
   frame_function_name = CompileFunction(&env,
@@ -6446,7 +6446,7 @@
 // break event in an eval statement the expected context is the one returned by
 // Message.GetEventContext.
 TEST(EvalContextData) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Debug::SetMessageHandler2(ContextCheckMessageHandler);
 
   ExecuteScriptForContextCheck();
@@ -6509,7 +6509,7 @@
 // Tests that context returned for break event is correct when the event occurs
 // in 'evaluate' debugger request.
 TEST(NestedBreakEventContextData) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   break_count = 0;
   message_handler_hit_count = 0;
   v8::Debug::SetMessageHandler2(DebugEvalContextCheckMessageHandler);
@@ -6544,8 +6544,8 @@
   v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
   break_point_hit_count = 0;
   script_collected_count = 0;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Request the loaded scripts to initialize the debugger script cache.
   debug->GetLoadedScripts();
@@ -6588,9 +6588,11 @@
 // Test that GetEventContext doesn't fail and return empty handle for
 // ScriptCollected events.
 TEST(ScriptCollectedEventContext) {
-  v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::internal::Debug* debug =
+      reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
   script_collected_message_count = 0;
-  v8::HandleScope scope;
+  v8::HandleScope scope(isolate);
 
   { // Scope for the DebugLocalContext.
     DebugLocalContext env;
@@ -6636,8 +6638,8 @@
 // Tests that after compile event is sent as many times as there are scripts
 // compiled.
 TEST(AfterCompileMessageWhenMessageHandlerIsReset) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   after_compile_message_count = 0;
   const char* script = "var a=1";
 
@@ -6660,8 +6662,8 @@
 
 // Tests that break event is sent when message handler is reset.
 TEST(BreakMessageWhenMessageHandlerIsReset) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   after_compile_message_count = 0;
   const char* script = "function f() {};";
 
@@ -6695,8 +6697,8 @@
 
 // Tests that exception event is sent when message handler is reset.
 TEST(ExceptionMessageWhenMessageHandlerIsReset) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // For this test, we want to break on uncaught exceptions:
   ChangeBreakOnException(false, true);
@@ -6724,8 +6726,8 @@
 // Tests after compile event is sent when there are some provisional
 // breakpoints out of the scripts lines range.
 TEST(ProvisionalBreakpointOnLineOutOfRange) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
   const char* script = "function f() {};";
   const char* resource_name = "test_resource";
@@ -6764,12 +6766,12 @@
     // Count the number of breaks.
     break_point_hit_count++;
 
-    v8::HandleScope scope;
+    i::HandleScope scope(isolate);
     message.GetJSON();
 
     SendContinueCommand();
   } else if (message.IsEvent() && message.GetEvent() == v8::AfterCompile) {
-    v8::HandleScope scope;
+    i::HandleScope scope(isolate);
 
     bool is_debug_break = isolate->stack_guard()->IsDebugBreak();
     // Force DebugBreak flag while serializer is working.
@@ -6791,8 +6793,8 @@
 // Test that if DebugBreak is forced it is ignored when code from
 // debug-delay.js is executed.
 TEST(NoDebugBreakInAfterCompileMessageHandler) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which sets the break flag and counts.
   v8::Debug::SetMessageHandler2(BreakMessageHandler);
@@ -6827,8 +6829,8 @@
 
 // Test that debug messages get processed when ProcessDebugMessages is called.
 TEST(ProcessDebugMessages) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   counting_message_handler_counter = 0;
 
@@ -6883,8 +6885,8 @@
 
 // Test that debug messages get processed when ProcessDebugMessages is called.
 TEST(Backtrace) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Debug::SetMessageHandler2(BacktraceData::MessageHandler);
 
@@ -6917,8 +6919,8 @@
 
 
 TEST(GetMirror) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Handle<v8::Value> obj = v8::Debug::GetMirror(v8::String::New("hodja"));
   v8::Handle<v8::Function> run_test = v8::Handle<v8::Function>::Cast(
       v8::Script::New(
@@ -6935,8 +6937,8 @@
 
 // Test that the debug break flag works with function.apply.
 TEST(DebugBreakFunctionApply) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Create a function for testing breaking in apply.
   v8::Local<v8::Function> foo = CompileFunction(
@@ -7013,8 +7015,8 @@
 TEST(CallingContextIsNotDebugContext) {
   v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
   // Create and enter a debugee context.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Save handles to the debugger and debugee contexts to be used in
@@ -7051,7 +7053,7 @@
 
 
 TEST(DebugContextIsPreservedBetweenAccesses) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Local<v8::Context> context1 = v8::Debug::GetDebugContext();
   v8::Local<v8::Context> context2 = v8::Debug::GetDebugContext();
   CHECK_EQ(*context1, *context2);
@@ -7066,7 +7068,7 @@
 
 // Check that event details contain context where debug event occured.
 TEST(DebugEventContext) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   expected_callback_data = v8::Int32::New(2010);
   v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
                                     expected_callback_data);
@@ -7096,8 +7098,8 @@
 
 // Check that event details contain context where debug event occured.
 TEST(DebugEventBreakData) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener2(DebugEventBreakDataChecker);
 
   TestClientData::constructor_call_counter = 0;
@@ -7179,8 +7181,8 @@
 // Test deoptimization when execution is broken using the debug break stack
 // check interrupt.
 TEST(DeoptimizeDuringDebugBreak) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   env.ExposeDebug();
 
   // Create a function for checking the function when hitting a break point.
@@ -7266,8 +7268,8 @@
 
 
 TEST(DebugBreakStackInspection) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   frame_function_name =
       CompileFunction(&env, frame_function_name_source, "frame_function_name");
@@ -7339,8 +7341,8 @@
 
 
 TEST(DebugBreakLoop) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Register a debug event listener which sets the break flag and counts.
   v8::Debug::SetDebugEventListener(DebugEventBreakMax);
@@ -7421,8 +7423,8 @@
 
 TEST(DebugBreakInline) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source =
       "function debug(b) {             \n"
       "  if (b) debugger;              \n"
@@ -7469,8 +7471,8 @@
   // recursive call.  In an attempt to step out, we crawl the stack using the
   // recorded frame pointer from the first script and fail when not finding it
   // on the stack.
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetDebugEventListener(DebugEventStepNext);
 
   // We step through the first script.  It exits through an exception.  We run
@@ -7499,8 +7501,8 @@
 
 
 TEST(DebuggerCreatesContextIffActive) {
-  v8::HandleScope scope;
   DebugLocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(1, CountNativeContexts());
 
   v8::Debug::SetDebugEventListener(NULL);
@@ -7517,8 +7519,8 @@
 
 TEST(LiveEditEnabled) {
   v8::internal::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-  LocalContext context;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetLiveEditEnabled(true);
   CompileRun("%LiveEditCompareStrings('', '')");
 }
@@ -7526,8 +7528,8 @@
 
 TEST(LiveEditDisabled) {
   v8::internal::FLAG_allow_natives_syntax = true;
-  v8::HandleScope scope;
-  LocalContext context;
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Debug::SetLiveEditEnabled(false);
   CompileRun("%LiveEditCompareStrings('', '')");
 }
diff --git a/test/cctest/test-declarative-accessors.cc b/test/cctest/test-declarative-accessors.cc
index 150059a..569848c 100644
--- a/test/cctest/test-declarative-accessors.cc
+++ b/test/cctest/test-declarative-accessors.cc
@@ -114,8 +114,8 @@
                        int internal_field,
                        void* internal_object,
                        v8::Handle<v8::Value> expected_value) {
-  v8::HandleScope scope;
   LocalContext local_context;
+  v8::HandleScope scope(local_context->GetIsolate());
   v8::Handle<v8::Context> context = local_context.local();
   CreateConstructor(context, "Accessible", internal_field, "x", descriptor);
   // Setup object.
@@ -168,7 +168,7 @@
     T value,
     v8::DeclaredAccessorDescriptorDataType data_type,
     DescriptorTestHelper* helper) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(helper->isolate_);
   int index = 17;
   int internal_field = 6;
   v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
@@ -194,7 +194,7 @@
 static void TestBitmaskCompare(T bitmask,
                                T compare_value,
                                DescriptorTestHelper* helper) {
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(helper->isolate_);
   int index = 13;
   int internal_field = 4;
   v8::Handle<v8::RawOperationDescriptor> raw_descriptor =
@@ -244,7 +244,7 @@
 
 TEST(PointerCompareRead) {
   DescriptorTestHelper helper;
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(helper.isolate_);
   int index = 35;
   int internal_field = 3;
   void* ptr = helper.isolate_;
@@ -261,7 +261,7 @@
 
 TEST(PointerDereferenceRead) {
   DescriptorTestHelper helper;
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(helper.isolate_);
   int first_index = 13;
   int internal_field = 7;
   int second_index = 11;
@@ -286,7 +286,7 @@
 
 TEST(HandleDereferenceRead) {
   DescriptorTestHelper helper;
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(helper.isolate_);
   int index = 13;
   int internal_field = 0;
   v8::Handle<v8::DeclaredAccessorDescriptor> descriptor =
@@ -299,4 +299,3 @@
                                                           expected);
   VerifyRead(descriptor, internal_field, array, expected);
 }
-
diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc
index efdc394..ae2ec71 100644
--- a/test/cctest/test-decls.cc
+++ b/test/cctest/test-decls.cc
@@ -113,7 +113,7 @@
 
 void DeclarationContext::InitializeIfNeeded() {
   if (is_initialized_) return;
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
   Local<FunctionTemplate> function = FunctionTemplate::New();
   Local<Value> data = External::New(this);
   GetHolder(function)->SetNamedPropertyHandler(&HandleGet,
@@ -136,7 +136,7 @@
   // A retry after a GC may pollute the counts, so perform gc now
   // to avoid that.
   HEAP->CollectGarbage(v8::internal::NEW_SPACE);
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
   TryCatch catcher;
   catcher.SetVerbose(true);
   Local<Script> script = Script::Compile(String::New(source));
@@ -215,7 +215,7 @@
 // Test global declaration of a property the interceptor doesn't know
 // about and doesn't handle.
 TEST(Unknown) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { DeclarationContext context;
     context.Check("var x; x",
@@ -270,7 +270,7 @@
 
 
 TEST(Present) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { PresentPropertyContext context;
     context.Check("var x; x",
@@ -324,7 +324,7 @@
 
 
 TEST(Absent) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { AbsentPropertyContext context;
     context.Check("var x; x",
@@ -414,7 +414,7 @@
 
 
 TEST(Appearing) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { AppearingPropertyContext context;
     context.Check("var x; x",
@@ -506,7 +506,7 @@
 
 
 TEST(Reappearing) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { ReappearingPropertyContext context;
     context.Check("const x; var x = 0",
@@ -535,7 +535,7 @@
 
 TEST(ExistsInPrototype) {
   i::FLAG_es52_globals = true;
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   // Sanity check to make sure that the holder of the interceptor
   // really is the prototype object.
@@ -598,7 +598,7 @@
 
 TEST(AbsentInPrototype) {
   i::FLAG_es52_globals = true;
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { AbsentInPrototypeContext context;
     context.Check("if (false) { var x = 0; }; x",
@@ -645,7 +645,7 @@
 
 TEST(ExistsInHiddenPrototype) {
   i::FLAG_es52_globals = true;
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { ExistsInHiddenPrototypeContext context;
     context.Check("var x; x",
@@ -707,7 +707,7 @@
   void Check(const char* source,
              Expectations expectations,
              v8::Handle<Value> value = Local<Value>()) {
-    HandleScope scope;
+    HandleScope scope(context_->GetIsolate());
     TryCatch catcher;
     catcher.SetVerbose(true);
     Local<Script> script = Script::Compile(String::New(source));
@@ -737,7 +737,7 @@
 
 
 TEST(CrossScriptReferences) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   { SimpleContext context;
     context.Check("var x = 1; x",
@@ -782,7 +782,7 @@
   i::FLAG_harmony_scoping = true;
   i::FLAG_harmony_modules = true;
 
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   const char* decs[] = {
     "var x = 1; x", "x", "this.x",
@@ -810,7 +810,7 @@
   i::FLAG_harmony_scoping = true;
   i::FLAG_harmony_modules = true;
 
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
 
   const char* firsts[] = {
     "var x = 1; x",
diff --git a/test/cctest/test-deoptimization.cc b/test/cctest/test-deoptimization.cc
index c52c578..620f6fe 100644
--- a/test/cctest/test-deoptimization.cc
+++ b/test/cctest/test-deoptimization.cc
@@ -113,8 +113,8 @@
 
 
 TEST(DeoptimizeSimple) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Test lazy deoptimization of a simple function.
   {
@@ -151,8 +151,8 @@
 
 
 TEST(DeoptimizeSimpleWithArguments) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Test lazy deoptimization of a simple function with some arguments.
   {
@@ -190,8 +190,8 @@
 
 
 TEST(DeoptimizeSimpleNested) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Test lazy deoptimization of a simple function. Have a nested function call
   // do the deoptimization.
@@ -215,8 +215,8 @@
 
 
 TEST(DeoptimizeRecursive) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   {
     // Test lazy deoptimization of a simple function called recursively. Call
@@ -242,8 +242,8 @@
 
 
 TEST(DeoptimizeMultiple) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   {
     AlwaysOptimizeAllowNativesSyntaxNoInlining options;
@@ -270,8 +270,8 @@
 
 
 TEST(DeoptimizeConstructor) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   {
     AlwaysOptimizeAllowNativesSyntaxNoInlining options;
@@ -308,8 +308,8 @@
 
 
 TEST(DeoptimizeConstructorMultiple) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   {
     AlwaysOptimizeAllowNativesSyntaxNoInlining options;
@@ -337,8 +337,8 @@
 
 
 TEST(DeoptimizeBinaryOperationADDString) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* f_source = "function f(x, y) { return x + y; };";
 
@@ -427,8 +427,8 @@
 
 
 TEST(DeoptimizeBinaryOperationADD) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   TestDeoptimizeBinaryOpHelper(&env, "+");
 
@@ -439,8 +439,8 @@
 
 
 TEST(DeoptimizeBinaryOperationSUB) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   TestDeoptimizeBinaryOpHelper(&env, "-");
 
@@ -451,8 +451,8 @@
 
 
 TEST(DeoptimizeBinaryOperationMUL) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   TestDeoptimizeBinaryOpHelper(&env, "*");
 
@@ -463,8 +463,8 @@
 
 
 TEST(DeoptimizeBinaryOperationDIV) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   TestDeoptimizeBinaryOpHelper(&env, "/");
 
@@ -475,8 +475,8 @@
 
 
 TEST(DeoptimizeBinaryOperationMOD) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   TestDeoptimizeBinaryOpHelper(&env, "%");
 
@@ -487,8 +487,8 @@
 
 
 TEST(DeoptimizeCompare) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const char* f_source = "function f(x, y) { return x < y; };";
 
@@ -530,8 +530,8 @@
 
 
 TEST(DeoptimizeLoadICStoreIC) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Functions to generate load/store/keyed load/keyed store IC calls.
   const char* f1_source = "function f1(x) { return x.y; };";
@@ -610,8 +610,8 @@
 
 
 TEST(DeoptimizeLoadICStoreICNested) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Functions to generate load/store/keyed load/keyed store IC calls.
   const char* f1_source = "function f1(x) { return x.y; };";
diff --git a/test/cctest/test-dictionary.cc b/test/cctest/test-dictionary.cc
index 2acd4e6..32fff60 100644
--- a/test/cctest/test-dictionary.cc
+++ b/test/cctest/test-dictionary.cc
@@ -40,8 +40,8 @@
 
 
 TEST(ObjectHashTable) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(23);
   Handle<JSObject> a = FACTORY->NewJSArray(7);
   Handle<JSObject> b = FACTORY->NewJSArray(11);
@@ -101,8 +101,8 @@
 
 #ifdef DEBUG
 TEST(ObjectHashSetCausesGC) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Handle<ObjectHashSet> table = FACTORY->NewObjectHashSet(1);
   Handle<JSObject> key = FACTORY->NewJSArray(0);
   v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
@@ -131,8 +131,8 @@
 
 #ifdef DEBUG
 TEST(ObjectHashTableCausesGC) {
-  v8::HandleScope scope;
   LocalContext context;
+  v8::HandleScope scope(context->GetIsolate());
   Handle<ObjectHashTable> table = FACTORY->NewObjectHashTable(1);
   Handle<JSObject> key = FACTORY->NewJSArray(0);
   v8::Handle<v8::Object> key_obj = v8::Utils::ToLocal(key);
diff --git a/test/cctest/test-disasm-arm.cc b/test/cctest/test-disasm-arm.cc
index 58e18a6..c7c770f 100644
--- a/test/cctest/test-disasm-arm.cc
+++ b/test/cctest/test-disasm-arm.cc
@@ -72,11 +72,12 @@
 // Set up V8 to a state where we can at least run the assembler and
 // disassembler. Declare the variables and allocate the data structures used
 // in the rest of the macros.
-#define SET_UP()                                           \
+#define SET_UP()                                          \
   InitializeVM();                                         \
-  v8::HandleScope scope;                                  \
+  Isolate* isolate = Isolate::Current();                  \
+  HandleScope scope(isolate);                             \
   byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \
-  Assembler assm(Isolate::Current(), buffer, 4*1024);     \
+  Assembler assm(isolate, buffer, 4*1024);                \
   bool failure = false;
 
 
diff --git a/test/cctest/test-disasm-ia32.cc b/test/cctest/test-disasm-ia32.cc
index 49e6738..8240a95 100644
--- a/test/cctest/test-disasm-ia32.cc
+++ b/test/cctest/test-disasm-ia32.cc
@@ -56,9 +56,10 @@
 
 TEST(DisasmIa320) {
   InitializeVM();
-  v8::HandleScope scope;
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
+  HandleScope scope(isolate);
   v8::internal::byte buffer[2048];
-  Assembler assm(Isolate::Current(), buffer, sizeof buffer);
+  Assembler assm(isolate, buffer, sizeof buffer);
   DummyStaticFunction(NULL);  // just bloody use it (DELETE; debugging)
 
   // Short immediate instructions
@@ -270,8 +271,7 @@
   __ bind(&L2);
   __ call(Operand(ebx, ecx, times_4, 10000));
   __ nop();
-  Handle<Code> ic(Isolate::Current()->builtins()->builtin(
-      Builtins::kLoadIC_Initialize));
+  Handle<Code> ic(isolate->builtins()->builtin(Builtins::kLoadIC_Initialize));
   __ call(ic, RelocInfo::CODE_TARGET);
   __ nop();
   __ call(FUNCTION_ADDR(DummyStaticFunction), RelocInfo::RUNTIME_ENTRY);
@@ -281,8 +281,7 @@
   __ jmp(Operand(ebx, ecx, times_4, 10000));
 #ifdef ENABLE_DEBUGGER_SUPPORT
   ExternalReference after_break_target =
-      ExternalReference(Debug_Address::AfterBreakTarget(),
-                        assm.isolate());
+      ExternalReference(Debug_Address::AfterBreakTarget(), isolate);
   __ jmp(Operand::StaticVariable(after_break_target));
 #endif  // ENABLE_DEBUGGER_SUPPORT
   __ jmp(ic, RelocInfo::CODE_TARGET);
@@ -459,7 +458,6 @@
 
   CodeDesc desc;
   assm.GetCode(&desc);
-  Isolate* isolate = Isolate::Current();
   Object* code = isolate->heap()->CreateCode(
       desc,
       Code::ComputeFlags(Code::STUB),
diff --git a/test/cctest/test-disasm-mips.cc b/test/cctest/test-disasm-mips.cc
index 1f87424..37aa5eb 100644
--- a/test/cctest/test-disasm-mips.cc
+++ b/test/cctest/test-disasm-mips.cc
@@ -74,11 +74,12 @@
 // Set up V8 to a state where we can at least run the assembler and
 // disassembler. Declare the variables and allocate the data structures used
 // in the rest of the macros.
-#define SET_UP()                                           \
+#define SET_UP()                                          \
   InitializeVM();                                         \
-  v8::HandleScope scope;                                  \
+  Isolate* isolate = Isolate::Current();                  \
+  HandleScope scope(isolate);                             \
   byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \
-  Assembler assm(Isolate::Current(), buffer, 4*1024);     \
+  Assembler assm(isolate, buffer, 4*1024);                \
   bool failure = false;
 
 
diff --git a/test/cctest/test-func-name-inference.cc b/test/cctest/test-func-name-inference.cc
index cda6aa0..364a4f6 100644
--- a/test/cctest/test-func-name-inference.cc
+++ b/test/cctest/test-func-name-inference.cc
@@ -52,10 +52,8 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
     env = v8::Context::New();
   }
-  v8::HandleScope scope;
   env->Enter();
 }
 
@@ -111,7 +109,7 @@
 
 TEST(GlobalProperty) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "fun1 = function() { return 1; }\n"
@@ -123,7 +121,7 @@
 
 TEST(GlobalVar) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "var fun1 = function() { return 1; }\n"
@@ -135,7 +133,7 @@
 
 TEST(LocalVar) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function outer() {\n"
@@ -149,7 +147,7 @@
 
 TEST(InConstructor) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function MyClass() {\n"
@@ -163,7 +161,7 @@
 
 TEST(Factory) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function createMyObj() {\n"
@@ -179,7 +177,7 @@
 
 TEST(Static) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function MyClass() {}\n"
@@ -197,7 +195,7 @@
 
 TEST(Prototype) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function MyClass() {}\n"
@@ -215,7 +213,7 @@
 
 TEST(ObjectLiteral) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function MyClass() {}\n"
@@ -229,7 +227,7 @@
 
 TEST(AsParameter) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function f1(a) { return a(); }\n"
@@ -245,7 +243,7 @@
 
 TEST(MultipleFuncsConditional) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "fun1 = 0 ?\n"
@@ -258,7 +256,7 @@
 
 TEST(MultipleFuncsInLiteral) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function MyClass() {}\n"
@@ -273,7 +271,7 @@
 // See http://code.google.com/p/v8/issues/detail?id=380
 TEST(Issue380) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function a() {\n"
@@ -286,7 +284,7 @@
 
 TEST(MultipleAssignments) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "var fun1 = fun2 = function () { return 1; }\n"
@@ -302,7 +300,7 @@
 
 TEST(AsConstructorParameter) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function Foo() {}\n"
@@ -316,7 +314,7 @@
 
 TEST(FactoryHashmap) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function createMyObj() {\n"
@@ -332,7 +330,7 @@
 
 TEST(FactoryHashmapVariable) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function createMyObj() {\n"
@@ -351,7 +349,7 @@
 
 TEST(FactoryHashmapConditional) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "function createMyObj() {\n"
@@ -366,7 +364,7 @@
 
 TEST(GlobalAssignmentAndCall) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "var Foo = function() {\n"
@@ -384,7 +382,7 @@
 
 TEST(AssignmentAndCall) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "(function Enclosing() {\n"
@@ -407,7 +405,7 @@
 
 TEST(MethodAssignmentInAnonymousFunctionCall) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "(function () {\n"
@@ -423,7 +421,7 @@
 
 TEST(ReturnAnonymousFunction) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::Script> script = Compile(
       "(function() {\n"
diff --git a/test/cctest/test-global-object.cc b/test/cctest/test-global-object.cc
index 16c0be0..b124b27 100644
--- a/test/cctest/test-global-object.cc
+++ b/test/cctest/test-global-object.cc
@@ -34,7 +34,7 @@
 // This test fails if properties on the prototype of the global object appear
 // as declared globals.
 TEST(StrictUndeclaredGlobalVariable) {
-  HandleScope scope;
+  HandleScope scope(Isolate::GetCurrent());
   v8::Local<v8::String> var_name = v8_str("x");
   LocalContext context;
   v8::TryCatch try_catch;
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc
index 8ef970f..263ad02 100644
--- a/test/cctest/test-heap-profiler.cc
+++ b/test/cctest/test-heap-profiler.cc
@@ -127,8 +127,8 @@
 
 
 TEST(HeapSnapshot) {
-  v8::HandleScope scope;
   LocalContext env2;
+  v8::HandleScope scope(env2->GetIsolate());
 
   CompileRun(
       "function A2() {}\n"
@@ -161,8 +161,8 @@
 
 
 TEST(HeapSnapshotObjectSizes) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   //   -a-> X1 --a
   // x -b-> X2 <-|
@@ -192,8 +192,8 @@
 
 
 TEST(BoundFunctionInSnapshot) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun(
       "function myFunction(a, b) { this.a = a; this.b = b; }\n"
       "function AAAAA() {}\n"
@@ -229,8 +229,8 @@
 
 
 TEST(HeapSnapshotEntryChildren) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function A() { }\n"
@@ -253,8 +253,8 @@
 
 
 TEST(HeapSnapshotCodeObjects) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function lazy(x) { return x - 1; }\n"
@@ -318,8 +318,8 @@
 
 
 TEST(HeapSnapshotHeapNumbers) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun(
       "a = 1;    // a is Smi\n"
       "b = 2.5;  // b is HeapNumber");
@@ -334,8 +334,8 @@
 }
 
 TEST(HeapSnapshotSlicedString) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun(
       "parent_string = \"123456789.123456789.123456789.123456789.123456789."
       "123456789.123456789.123456789.123456789.123456789."
@@ -357,7 +357,7 @@
 }
 
 TEST(HeapSnapshotInternalReferences) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
   global_template->SetInternalFieldCount(2);
   LocalContext env(NULL, global_template);
@@ -386,8 +386,8 @@
   CHECK((a) != (b))  // NOLINT
 
 TEST(HeapSnapshotAddressReuse) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function A() {}\n"
@@ -424,8 +424,8 @@
 
 
 TEST(HeapEntryIdsAndArrayShift) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function AnObject() {\n"
@@ -470,8 +470,8 @@
 }
 
 TEST(HeapEntryIdsAndGC) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function A() {}\n"
@@ -532,8 +532,8 @@
 
 
 TEST(HeapSnapshotRootPreservedAfterSorting) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("s"));
   const v8::HeapGraphNode* root1 = snapshot->GetRoot();
@@ -590,8 +590,8 @@
 }  // namespace
 
 TEST(HeapSnapshotJSONSerialization) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
 #define STRING_LITERAL_FOR_TEST \
   "\"String \\n\\r\\u0008\\u0081\\u0101\\u0801\\u8001\""
@@ -692,8 +692,8 @@
 
 
 TEST(HeapSnapshotJSONSerializationAborting) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("abort"));
   TestJSONStream stream(5);
@@ -773,8 +773,8 @@
 
 
 TEST(HeapSnapshotObjectsStats) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::HeapProfiler::StartHeapObjectsTracking();
   // We have to call GC 6 times. In other case the garbage will be
@@ -800,7 +800,7 @@
 
   {
     v8::SnapshotObjectId additional_string_id;
-    v8::HandleScope inner_scope_1;
+    v8::HandleScope inner_scope_1(env->GetIsolate());
     v8_str("string1");
     {
       // Single chunk of data with one new entry expected in update.
@@ -819,12 +819,12 @@
     CHECK_EQ_SNAPSHOT_OBJECT_ID(additional_string_id, last_id);
 
     {
-      v8::HandleScope inner_scope_2;
+      v8::HandleScope inner_scope_2(env->GetIsolate());
       v8_str("string2");
 
       uint32_t entries_size;
       {
-        v8::HandleScope inner_scope_3;
+        v8::HandleScope inner_scope_3(env->GetIsolate());
         v8_str("string3");
         v8_str("string4");
 
@@ -926,8 +926,8 @@
 
 
 TEST(HeapSnapshotGetNodeById) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("id"));
@@ -939,8 +939,8 @@
 
 
 TEST(HeapSnapshotGetSnapshotObjectId) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun("globalObject = {};\n");
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("get_snapshot_object_id"));
@@ -963,8 +963,8 @@
 
 
 TEST(HeapSnapshotUnknownSnapshotObjectId) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun("globalObject = {};\n");
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("unknown_object_id"));
@@ -996,8 +996,8 @@
 }
 
 TEST(TakeHeapSnapshotAborting) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const int snapshots_count = v8::HeapProfiler::GetSnapshotsCount();
   TestActivityControl aborting_control(1);
@@ -1106,9 +1106,9 @@
 
 
 TEST(HeapSnapshotRetainedObjectInfo) {
-  v8::HandleScope scope;
   LocalContext env;
   v8::Isolate* isolate = env->GetIsolate();
+  v8::HandleScope scope(isolate);
 
   v8::HeapProfiler::DefineWrapperClass(
       1, TestRetainedObjectInfo::WrapperInfoCallback);
@@ -1203,8 +1203,8 @@
 
 
 TEST(HeapSnapshotImplicitReferences) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   GraphWithImplicitRefs graph(&env);
   v8::V8::AddGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
@@ -1235,8 +1235,8 @@
 
 
 TEST(DeleteAllHeapSnapshots) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
   v8::HeapProfiler::DeleteAllSnapshots();
@@ -1254,8 +1254,8 @@
 
 
 TEST(DeleteHeapSnapshot) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK_EQ(0, v8::HeapProfiler::GetSnapshotsCount());
   const v8::HeapSnapshot* s1 =
@@ -1300,8 +1300,8 @@
 };
 
 TEST(GlobalObjectName) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("document = { URL:\"abcdefgh\" };");
 
@@ -1320,8 +1320,8 @@
 
 
 TEST(NoHandleLeaks) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("document = { URL:\"abcdefgh\" };");
 
@@ -1335,8 +1335,8 @@
 
 
 TEST(NodesIteration) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("iteration"));
   const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
@@ -1353,8 +1353,8 @@
 
 
 TEST(GetHeapValue) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("a = { s_prop: \'value\', n_prop: 0.1 };");
   const v8::HeapSnapshot* snapshot =
@@ -1383,8 +1383,8 @@
 
 
 TEST(GetHeapValueForDeletedObject) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   // It is impossible to delete a global property, so we are about to delete a
   // property of the "a" object. Also, the "p" object can't be an empty one
@@ -1400,7 +1400,7 @@
   {
     // Perform the check inside a nested local scope to avoid creating a
     // reference to the object we are deleting.
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     CHECK(prop->GetHeapValue()->IsObject());
   }
   CompileRun("delete a.p;");
@@ -1418,8 +1418,8 @@
 
 
 TEST(GetConstructorName) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function Constructor1() {};\n"
@@ -1465,8 +1465,8 @@
 
 
 TEST(FastCaseGetter) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("var obj1 = {};\n"
              "obj1.__defineGetter__('propWithGetter', function Y() {\n"
@@ -1492,8 +1492,8 @@
 }
 
 TEST(HiddenPropertiesFastCase) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "function C(x) { this.a = this; this.b = x; }\n"
@@ -1552,8 +1552,8 @@
 
 
 TEST(WeakGlobalHandle) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CHECK(!HasWeakGlobalHandle());
 
@@ -1566,8 +1566,8 @@
 
 
 TEST(WeakNativeContextRefs) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("weaks"));
@@ -1585,8 +1585,8 @@
 
 
 TEST(SfiAndJsFunctionWeakRefs) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "fun = (function (x) { return function () { return x + 1; } })(1);");
@@ -1605,8 +1605,8 @@
 
 #ifdef ENABLE_DEBUGGER_SUPPORT
 TEST(NoDebugObjectInSnapshot) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::internal::Isolate::Current()->debug()->Load();
   CompileRun("foo = {};");
@@ -1630,9 +1630,9 @@
 
 
 TEST(PersistentHandleCount) {
-  v8::HandleScope scope;
   LocalContext env;
   v8::Isolate* isolate = env->GetIsolate();
+  v8::HandleScope scope(isolate);
 
   // V8 also uses global handles internally, so we can't test for an absolute
   // number.
@@ -1665,8 +1665,8 @@
 
 
 TEST(AllStrongGcRootsHaveNames) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun("foo = {};");
   const v8::HeapSnapshot* snapshot =
@@ -1687,8 +1687,8 @@
 
 
 TEST(NoRefsToNonEssentialEntries) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun("global_object = {};\n");
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
@@ -1706,8 +1706,8 @@
 
 
 TEST(MapHasDescriptorsAndTransitions) {
-  v8::HandleScope scope;
   LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
   CompileRun("obj = { a: 10 };\n");
   const v8::HeapSnapshot* snapshot =
       v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
@@ -1726,3 +1726,46 @@
       map, v8::HeapGraphEdge::kInternal, "transitions");
   CHECK_EQ(NULL, own_transitions);
 }
+
+
+TEST(ManyLocalsInSharedContext) {
+  v8::HandleScope scope;
+  LocalContext env;
+  int num_objects = 6000;
+  CompileRun(
+      "var n = 6000;"
+      "var result = [];"
+      "result.push('(function outer() {');"
+      "for (var i = 0; i < n; i++) {"
+      "    var f = 'function f_' + i + '() { ';"
+      "    if (i > 0)"
+      "        f += 'f_' + (i - 1) + '();';"
+      "    f += ' }';"
+      "    result.push(f);"
+      "}"
+      "result.push('return f_' + (n - 1) + ';');"
+      "result.push('})()');"
+      "var ok = eval(result.join('\\n'));");
+  const v8::HeapSnapshot* snapshot =
+      v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
+  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
+  CHECK_NE(NULL, global);
+  const v8::HeapGraphNode* ok_object =
+      GetProperty(global, v8::HeapGraphEdge::kProperty, "ok");
+  CHECK_NE(NULL, ok_object);
+  const v8::HeapGraphNode* context_object =
+      GetProperty(ok_object, v8::HeapGraphEdge::kInternal, "context");
+  CHECK_NE(NULL, context_object);
+  // Check the objects are not duplicated in the context.
+  CHECK_EQ(v8::internal::Context::MIN_CONTEXT_SLOTS + num_objects - 1,
+           context_object->GetChildrenCount());
+  // Check all the objects have got their names.
+  // ... well check just every 8th because otherwise it's too slow in debug.
+  for (int i = 0; i < num_objects - 1; i += 8) {
+    i::EmbeddedVector<char, 100> var_name;
+    i::OS::SNPrintF(var_name, "f_%d", i);
+    const v8::HeapGraphNode* f_object = GetProperty(
+        context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
+    CHECK_NE(NULL, f_object);
+  }
+}
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 7cdae6b..e1da9ef 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -43,7 +43,6 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) env = v8::Context::New();
-  v8::HandleScope scope;
   env->Enter();
 }
 
@@ -156,7 +155,7 @@
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
 
-  v8::HandleScope sc;
+  HandleScope sc(isolate);
   Object* value = heap->NumberFromDouble(1.000123)->ToObjectChecked();
   CHECK(value->IsHeapNumber());
   CHECK(value->IsNumber());
@@ -258,7 +257,7 @@
   Heap* heap = isolate->heap();
   Factory* factory = isolate->factory();
 
-  v8::HandleScope sc;
+  HandleScope sc(isolate);
   // Check GC.
   heap->CollectGarbage(NEW_SPACE);
 
@@ -323,9 +322,9 @@
 }
 
 
-static void VerifyStringAllocation(const char* string) {
-  v8::HandleScope scope;
-  Handle<String> s = FACTORY->NewStringFromUtf8(CStrVector(string));
+static void VerifyStringAllocation(Isolate* isolate, const char* string) {
+  HandleScope scope(isolate);
+  Handle<String> s = isolate->factory()->NewStringFromUtf8(CStrVector(string));
   CHECK_EQ(StrLength(string), s->length());
   for (int index = 0; index < s->length(); index++) {
     CHECK_EQ(static_cast<uint16_t>(string[index]), s->Get(index));
@@ -335,19 +334,20 @@
 
 TEST(String) {
   InitializeVM();
+  Isolate* isolate = reinterpret_cast<Isolate*>(env->GetIsolate());
 
-  VerifyStringAllocation("a");
-  VerifyStringAllocation("ab");
-  VerifyStringAllocation("abc");
-  VerifyStringAllocation("abcd");
-  VerifyStringAllocation("fiskerdrengen er paa havet");
+  VerifyStringAllocation(isolate, "a");
+  VerifyStringAllocation(isolate, "ab");
+  VerifyStringAllocation(isolate, "abc");
+  VerifyStringAllocation(isolate, "abcd");
+  VerifyStringAllocation(isolate, "fiskerdrengen er paa havet");
 }
 
 
 TEST(LocalHandles) {
   InitializeVM();
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* name = "Kasper the spunky";
   Handle<String> string = FACTORY->NewStringFromAscii(CStrVector(name));
   CHECK_EQ(StrLength(name), string->length());
@@ -620,7 +620,7 @@
 TEST(FunctionAllocation) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
   Handle<JSFunction> function =
       FACTORY->NewFunction(name, FACTORY->undefined_value());
@@ -643,7 +643,7 @@
 TEST(ObjectProperties) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   String* object_string = String::cast(HEAP->Object_string());
   Object* raw_object = Isolate::Current()->context()->global_object()->
       GetProperty(object_string)->ToObjectChecked();
@@ -716,7 +716,7 @@
 TEST(JSObjectMaps) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   Handle<String> name = FACTORY->InternalizeUtf8String("theFunction");
   Handle<JSFunction> function =
       FACTORY->NewFunction(name, FACTORY->undefined_value());
@@ -740,7 +740,7 @@
 TEST(JSArray) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   Handle<String> name = FACTORY->InternalizeUtf8String("Array");
   Object* raw_object = Isolate::Current()->context()->global_object()->
       GetProperty(*name)->ToObjectChecked();
@@ -787,7 +787,7 @@
 TEST(JSObjectCopy) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   String* object_string = String::cast(HEAP->Object_string());
   Object* raw_object = Isolate::Current()->context()->global_object()->
       GetProperty(object_string)->ToObjectChecked();
@@ -835,10 +835,9 @@
 TEST(StringAllocation) {
   InitializeVM();
 
-
   const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 };
   for (int length = 0; length < 100; length++) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     char* non_ascii = NewArray<char>(3 * length + 1);
     char* ascii = NewArray<char>(length + 1);
     non_ascii[3 * length] = 0;
@@ -887,7 +886,7 @@
 
 TEST(Iteration) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Array of objects to scan haep for.
   const int objs_count = 6;
@@ -926,11 +925,11 @@
 TEST(EmptyHandleEscapeFrom) {
   InitializeVM();
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   Handle<JSObject> runaway;
 
   {
-      v8::HandleScope nested;
+      v8::HandleScope nested(env->GetIsolate());
       Handle<JSObject> empty;
       runaway = empty.EscapeFrom(&nested);
   }
@@ -951,7 +950,7 @@
   // Increase the chance of 'bump-the-pointer' allocation in old space.
   HEAP->CollectAllGarbage(Heap::kNoGCFlags);
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // The plan: create JSObject which references objects in new space.
   // Then clone this object (forcing it to go into old space) and check
@@ -1024,7 +1023,7 @@
   if (!FLAG_flush_code) return;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "function foo() {"
                        "  var x = 42;"
                        "  var y = 42;"
@@ -1034,7 +1033,7 @@
   Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
 
   // This compile will add the code to the compilation cache.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun(source);
   }
 
@@ -1071,7 +1070,7 @@
   if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "function foo() {"
                        "  var x = 42;"
                        "  var y = 42;"
@@ -1081,7 +1080,7 @@
   Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
 
   // This compile will add the code to the compilation cache.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun(source);
   }
 
@@ -1107,7 +1106,7 @@
   CHECK(!function->is_compiled() || function->IsOptimized());
 
   // This compile will compile the function again.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun("foo();");
   }
 
@@ -1121,7 +1120,7 @@
 
   // Force optimization while incremental marking is active and while
   // the function is enqueued as a candidate.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
   }
 
@@ -1137,7 +1136,7 @@
   if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "var foo = function() {"
                        "  var x = 42;"
                        "  var y = 42;"
@@ -1155,7 +1154,7 @@
   HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
 
   // This compile will add the code to the compilation cache.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun(source);
   }
 
@@ -1172,7 +1171,7 @@
   CHECK(function2->shared()->is_compiled());
 
   // Clear references to functions so that one of them can die.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun("foo = 0; bar = 0;");
   }
 
@@ -1205,7 +1204,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "function foo() {"
                        "  var x = 42;"
                        "  var y = 42;"
@@ -1215,7 +1214,7 @@
   Handle<String> foo_name = FACTORY->InternalizeUtf8String("foo");
 
   // This compile will add the code to the compilation cache.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun(source);
   }
 
@@ -1250,7 +1249,7 @@
   isolate->debug()->ClearAllBreakPoints();
 
   // Force optimization now that code flushing is disabled.
-  { v8::HandleScope scope;
+  { v8::HandleScope scope(env->GetIsolate());
     CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
   }
 
@@ -1298,7 +1297,7 @@
 
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   v8::Persistent<v8::Context> ctx[kNumTestContexts];
 
   CHECK_EQ(0, CountNativeContexts());
@@ -1315,7 +1314,7 @@
 
     // Create a handle scope so no function objects get stuch in the outer
     // handle scope
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     const char* source = "function f1() { };"
                          "function f2() { };"
                          "function f3() { };"
@@ -1435,7 +1434,7 @@
 
   static const int kNumTestContexts = 10;
 
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   v8::Persistent<v8::Context> ctx[kNumTestContexts];
 
   CHECK_EQ(0, CountNativeContexts());
@@ -1559,12 +1558,15 @@
 static void FillUpNewSpace(NewSpace* new_space) {
   // Fill up new space to the point that it is completely full. Make sure
   // that the scavenger does not undo the filling.
-  v8::HandleScope scope;
+  Heap* heap = new_space->heap();
+  Isolate* isolate = heap->isolate();
+  Factory* factory = isolate->factory();
+  HandleScope scope(isolate);
   AlwaysAllocateScope always_allocate;
   intptr_t available = new_space->EffectiveCapacity() - new_space->Size();
   intptr_t number_of_fillers = (available / FixedArray::SizeFor(32)) - 1;
   for (intptr_t i = 0; i < number_of_fillers; i++) {
-    CHECK(HEAP->InNewSpace(*FACTORY->NewFixedArray(32, NOT_TENURED)));
+    CHECK(heap->InNewSpace(*factory->NewFixedArray(32, NOT_TENURED)));
   }
 }
 
@@ -1630,7 +1632,7 @@
     return;
   }
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   NewSpace* new_space = HEAP->new_space();
   intptr_t old_capacity, new_capacity;
   old_capacity = new_space->Capacity();
@@ -1658,7 +1660,7 @@
 // optimized code.
 TEST(LeakNativeContextViaMap) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> ctx1 = v8::Context::New();
   v8::Persistent<v8::Context> ctx2 = v8::Context::New();
   ctx1->Enter();
@@ -1667,7 +1669,7 @@
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     CompileRun("var v = {x: 42}");
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
@@ -1696,7 +1698,7 @@
 // optimized code.
 TEST(LeakNativeContextViaFunction) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> ctx1 = v8::Context::New();
   v8::Persistent<v8::Context> ctx2 = v8::Context::New();
   ctx1->Enter();
@@ -1705,7 +1707,7 @@
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     CompileRun("var v = function() { return 42; }");
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
@@ -1732,7 +1734,7 @@
 
 TEST(LeakNativeContextViaMapKeyed) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> ctx1 = v8::Context::New();
   v8::Persistent<v8::Context> ctx2 = v8::Context::New();
   ctx1->Enter();
@@ -1741,7 +1743,7 @@
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     CompileRun("var v = [42, 43]");
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
@@ -1768,7 +1770,7 @@
 
 TEST(LeakNativeContextViaMapProto) {
   i::FLAG_allow_natives_syntax = true;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> ctx1 = v8::Context::New();
   v8::Persistent<v8::Context> ctx2 = v8::Context::New();
   ctx1->Enter();
@@ -1777,7 +1779,7 @@
   CHECK_EQ(4, NumberOfGlobalObjects());
 
   {
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(v8::Isolate::GetCurrent());
     CompileRun("var v = { y: 42}");
     v8::Local<v8::Value> v = ctx1->Global()->Get(v8_str("v"));
     ctx2->Enter();
@@ -1815,10 +1817,10 @@
   InitializeVM();
   if (!i::V8::UseCrankshaft()) return;
   if (i::FLAG_force_marking_deque_overflows) return;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     CompileRun(
         "function foo () { }"
         "function mkbar () { return new (new Function(\"\")) (); }"
@@ -1850,7 +1852,7 @@
   CHECK(marking->IsMarking());
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global();
     v8::Handle<v8::Function> g =
         v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
@@ -1864,7 +1866,7 @@
 
 TEST(PrototypeTransitionClearing) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   CompileRun(
       "var base = {};"
@@ -1928,10 +1930,10 @@
 
   InitializeVM();
   if (!i::V8::UseCrankshaft()) return;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     CompileRun(
         "function f () {"
         "  var s = 0;"
@@ -1984,10 +1986,10 @@
 
   InitializeVM();
   if (!i::V8::UseCrankshaft()) return;
-  v8::HandleScope outer_scope;
+  v8::HandleScope outer_scope(env->GetIsolate());
 
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     CompileRun(
         "function f () {"
         "  var s = 0;"
@@ -2024,7 +2026,7 @@
   InitializeVM();
   if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
   if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   SimulateFullSpace(HEAP->new_space());
   AlwaysAllocateScope always_allocate;
@@ -2051,31 +2053,27 @@
 // Test pretenuring of array literals allocated with HAllocate.
 TEST(OptimizedPretenuringArrayLiterals) {
   i::FLAG_allow_natives_syntax = true;
+  i::FLAG_pretenure_literals = true;
   InitializeVM();
   if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
   if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   AlwaysAllocateScope always_allocate;
   v8::Local<v8::Value> res = CompileRun(
       "function f() {"
-      "  var numbers = new Array(1, 2, 3);"
-      "  numbers[0] = 3.14;"
+      "  var numbers = [1, 2, 3];"
+      "  numbers[0] = {};"
       "  return numbers;"
       "};"
       "f(); f(); f();"
       "%OptimizeFunctionOnNextCall(f);"
       "f();");
-  CHECK_EQ(static_cast<int>(3.14),
-           v8::Object::Cast(*res)->Get(v8_str("0"))->Int32Value());
 
   Handle<JSObject> o =
       v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
 
-  // TODO(hpayer): remove InNewSpace check and test if object was allocated
-  // in old pointer space.
-  CHECK(!HEAP->InOldPointerSpace(*o));
-  CHECK(HEAP->InNewSpace(*o));
+  CHECK(HEAP->InOldPointerSpace(o->elements()));
 }
 
 
@@ -2085,7 +2083,7 @@
   InitializeVM();
   if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
   if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   AlwaysAllocateScope always_allocate;
   v8::Local<v8::Value> res = CompileRun(
@@ -2103,7 +2101,7 @@
   Handle<JSObject> o =
       v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res));
 
-  CHECK(HEAP->InNewSpace(*o));
+  CHECK(HEAP->InNewSpace(o->elements()));
 }
 
 
@@ -2118,7 +2116,7 @@
   i::FLAG_allow_natives_syntax = true;
   i::FLAG_trace_incremental_marking = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   static const int transitions_count = 256;
 
   {
@@ -2156,7 +2154,7 @@
   i::FLAG_collect_maps = true;
   i::FLAG_incremental_marking = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Prepare a map transition from the root object together with a yet
   // untransitioned root object.
@@ -2197,7 +2195,7 @@
   i::FLAG_incremental_marking = true;
   i::FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Prepare a map transition from the root object together with a yet
   // untransitioned root object.
@@ -2242,7 +2240,7 @@
   i::FLAG_crankshaft = false;
   i::FLAG_always_opt = false;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   static const int number_of_test_pages = 20;
 
   // Prepare many pages with low live-bytes count.
@@ -2281,12 +2279,12 @@
 
 TEST(Regress2237) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   Handle<String> slice(HEAP->empty_string());
 
   {
     // Generate a parent that lives in new-space.
-    v8::HandleScope inner_scope;
+    v8::HandleScope inner_scope(env->GetIsolate());
     const char* c = "This text is long enough to trigger sliced strings.";
     Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
     CHECK(s->IsSeqOneByteString());
@@ -2311,7 +2309,7 @@
 #ifdef OBJECT_PRINT
 TEST(PrintSharedFunctionInfo) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   const char* source = "f = function() { return 987654321; }\n"
                        "g = function() { return 123456789; }\n";
   CompileRun(source);
@@ -2328,7 +2326,7 @@
 
 TEST(Regress2211) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   v8::Handle<v8::String> value = v8_str("val string");
   Smi* hash = Smi::FromInt(321);
@@ -2366,7 +2364,7 @@
 TEST(IncrementalMarkingClearsTypeFeedbackCells) {
   if (i::FLAG_always_opt) return;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> fun1, fun2;
 
   {
@@ -2425,7 +2423,7 @@
 TEST(IncrementalMarkingPreservesMonomorhpicIC) {
   if (i::FLAG_always_opt) return;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Prepare function f that contains a monomorphic IC for object
   // originating from the same native context.
@@ -2450,7 +2448,7 @@
 TEST(IncrementalMarkingClearsMonomorhpicIC) {
   if (i::FLAG_always_opt) return;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> obj1;
 
   {
@@ -2484,7 +2482,7 @@
 TEST(IncrementalMarkingClearsPolymorhpicIC) {
   if (i::FLAG_always_opt) return;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> obj1, obj2;
 
   {
@@ -2550,10 +2548,10 @@
   // to check whether the data is being released since the external string
   // resource's callback is fired when the external string is GC'ed.
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   SourceResource* resource = new SourceResource(i::StrDup(source));
   {
-    v8::HandleScope scope;
+    v8::HandleScope scope(env->GetIsolate());
     v8::Handle<v8::String> source_string = v8::String::NewExternal(resource);
     v8::Script::Compile(source_string)->Run();
     CHECK(!resource->IsDisposed());
@@ -2588,12 +2586,12 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // First make sure that the uninitialized CallIC stub is on a single page
   // that will later be selected as an evacuation candidate.
   {
-    v8::HandleScope inner_scope;
+    HandleScope inner_scope(isolate);
     AlwaysAllocateScope always_allocate;
     SimulateFullSpace(heap->code_space());
     isolate->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET);
@@ -2602,7 +2600,7 @@
   // Second compile a CallIC and execute it once so that it gets patched to
   // the pre-monomorphic stub. These code objects are on yet another page.
   {
-    v8::HandleScope inner_scope;
+    HandleScope inner_scope(isolate);
     AlwaysAllocateScope always_allocate;
     SimulateFullSpace(heap->code_space());
     CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};"
@@ -2613,7 +2611,7 @@
   // Third we fill up the last page of the code space so that it does not get
   // chosen as an evacuation candidate.
   {
-    v8::HandleScope inner_scope;
+    HandleScope inner_scope(isolate);
     AlwaysAllocateScope always_allocate;
     CompileRun("for (var i = 0; i < 2000; i++) {"
                "  eval('function f' + i + '() { return ' + i +'; };' +"
@@ -2651,7 +2649,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // Perform one initial GC to enable code flushing.
   heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -2713,7 +2711,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // Perform one initial GC to enable code flushing.
   heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -2761,7 +2759,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // Perform one initial GC to enable code flushing.
   heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -2845,7 +2843,7 @@
   i::FLAG_allow_natives_syntax = true;
   i::FLAG_crankshaft = false;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   // Some flags turn Scavenge collections into Mark-sweep collections
   // and hence are incompatible with this test case.
@@ -2920,7 +2918,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // Perform one initial GC to enable code flushing.
   heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
@@ -2976,7 +2974,7 @@
   InitializeVM();
   Isolate* isolate = Isolate::Current();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
 
   // Perform one initial GC to enable code flushing.
   heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
diff --git a/test/cctest/test-lockers.cc b/test/cctest/test-lockers.cc
index cd37546..a54390b 100644
--- a/test/cctest/test-lockers.cc
+++ b/test/cctest/test-lockers.cc
@@ -69,7 +69,7 @@
       v8::Locker locker(isolate_);
       v8::Isolate::Scope isolate_scope(isolate_);
       CHECK_EQ(isolate_, v8::internal::Isolate::Current());
-      v8::HandleScope scope;
+      v8::HandleScope scope(isolate_);
       v8::Context::Scope context_scope(context_);
       Local<Value> v = CompileRun("getValue()");
       CHECK(v->IsNumber());
@@ -79,7 +79,7 @@
       v8::Locker locker(isolate_);
       v8::Isolate::Scope isolate_scope(isolate_);
       v8::Context::Scope context_scope(context_);
-      v8::HandleScope scope;
+      v8::HandleScope scope(isolate_);
       Local<Value> v = CompileRun("getValue()");
       CHECK(v->IsNumber());
       CHECK_EQ(30, static_cast<int>(v->NumberValue()));
@@ -99,7 +99,7 @@
   {
     v8::Locker locker(isolate);
     v8::Isolate::Scope isolate_scope(isolate);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     context = v8::Context::New();
     v8::Context::Scope context_scope(context);
     CHECK_EQ(isolate, v8::internal::Isolate::Current());
@@ -179,7 +179,7 @@
   virtual void Run() {
     v8::Locker locker(isolate_);
     v8::Isolate::Scope isolate_scope(isolate_);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate_);
     LocalContext local_context;
     CHECK_EQ(isolate_, v8::internal::Isolate::Current());
     CalcFibAndCheck();
@@ -227,7 +227,7 @@
     v8::Isolate* isolate = v8::Isolate::New();
     {
       v8::Isolate::Scope isolate_scope(isolate);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate);
       v8::Handle<v8::Context> context = v8::Context::New();
       v8::Context::Scope context_scope(context);
       CHECK_EQ(isolate, v8::internal::Isolate::Current());
@@ -261,7 +261,7 @@
   virtual void Run() {
     v8::Locker lock(isolate_);
     v8::Isolate::Scope isolate_scope(isolate_);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate_);
     LocalContext local_context;
     {
       v8::Locker another_lock(isolate_);
@@ -304,7 +304,7 @@
   virtual void Run() {
     v8::Locker lock(isolate1_);
     v8::Isolate::Scope isolate_scope(isolate1_);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate1_);
     LocalContext local_context;
 
     IsolateLockingThreadWithLocalContext threadB(isolate2_);
@@ -348,7 +348,7 @@
   virtual void Run() {
     v8::Locker lock(isolate_);
     v8::Isolate::Scope isolate_scope(isolate_);
-    HandleScope handle_scope;
+    HandleScope handle_scope(isolate_);
     v8::Context::Scope context_scope(context_);
     CalcFibAndCheck();
   }
@@ -367,7 +367,7 @@
   virtual void Run() {
     v8::Locker lock(isolate_);
     v8::Isolate::Scope isolate_scope(isolate_);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate_);
     v8::Handle<v8::Context> context = v8::Context::New();
     {
       v8::Context::Scope context_scope(context);
@@ -417,7 +417,7 @@
   virtual void Run() {
     v8::Locker lock(isolate_);
     v8::Isolate::Scope isolate_scope(isolate_);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate_);
     v8::Handle<v8::Context> context = v8::Context::New();
     {
       v8::Context::Scope context_scope(context);
@@ -477,7 +477,7 @@
     CHECK(!v8::Locker::IsLocked(isolate2_));
     {
       v8::Isolate::Scope isolate_scope(isolate1_);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate1_);
       context1 = v8::Context::New();
       {
         v8::Context::Scope context_scope(context1);
@@ -489,7 +489,7 @@
     CHECK(v8::Locker::IsLocked(isolate2_));
     {
       v8::Isolate::Scope isolate_scope(isolate2_);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate2_);
       context2 = v8::Context::New();
       {
         v8::Context::Scope context_scope(context2);
@@ -501,7 +501,7 @@
       CHECK(!v8::Locker::IsLocked(isolate1_));
       CHECK(v8::Locker::IsLocked(isolate2_));
       v8::Isolate::Scope isolate_scope(isolate2_);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate2_);
       v8::Context::Scope context_scope(context2);
       LockIsolateAndCalculateFibSharedContextThread thread(isolate1_, context1);
       thread.Start();
@@ -540,7 +540,7 @@
     CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
     {
       v8::Isolate::Scope isolate_scope(isolate_);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate_);
       v8::Context::Scope context_scope(context_);
       CalcFibAndCheck();
     }
@@ -551,7 +551,7 @@
       {
         v8::Locker lock2(isolate_);
         v8::Isolate::Scope isolate_scope(isolate_);
-        v8::HandleScope handle_scope;
+        v8::HandleScope handle_scope(isolate_);
         CHECK(v8::Locker::IsLocked(isolate_));
         CHECK(!v8::Locker::IsLocked(CcTest::default_isolate()));
         v8::Context::Scope context_scope(context_);
@@ -577,7 +577,7 @@
   {
     v8::Locker locker_(isolate);
     v8::Isolate::Scope isolate_scope(isolate);
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(isolate);
     context = v8::Context::New();
   }
   i::List<JoinableThread*> threads(kNThreads);
@@ -598,7 +598,7 @@
   virtual void Run() {
     v8::Locker lock1(CcTest::default_isolate());
     {
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(CcTest::default_isolate());
       v8::Context::Scope context_scope(context_);
       CalcFibAndCheck();
     }
@@ -606,7 +606,7 @@
       v8::Unlocker unlock1(CcTest::default_isolate());
       {
         v8::Locker lock2(CcTest::default_isolate());
-        v8::HandleScope handle_scope;
+        v8::HandleScope handle_scope(CcTest::default_isolate());
         v8::Context::Scope context_scope(context_);
         CalcFibAndCheck();
       }
@@ -627,7 +627,7 @@
   Persistent<v8::Context> context;
   {
     v8::Locker locker_(CcTest::default_isolate());
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(CcTest::default_isolate());
     context = v8::Context::New();
   }
   i::List<JoinableThread*> threads(kNThreads);
@@ -644,7 +644,7 @@
     {
       v8::Locker lock(isolate);
       v8::Isolate::Scope isolate_scope(isolate);
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(isolate);
       v8::Persistent<Context> context = v8::Context::New();
       v8::Context::Scope context_scope(context);
       v8::Handle<String> source = v8::String::New("1+1");
diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc
index 8fe6916..c27d5b8 100644
--- a/test/cctest/test-log-stack-tracer.cc
+++ b/test/cctest/test-log-stack-tracer.cc
@@ -172,7 +172,7 @@
 
 v8::Handle<v8::Value> TraceExtension::JSEntrySPLevel2(
     const v8::Arguments& args) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(args.GetIsolate());
   const Address js_entry_sp = GetJsEntrySp();
   CHECK_NE(0, js_entry_sp);
   CompileRun("js_entry_sp();");
@@ -187,12 +187,10 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
     const char* extensions[] = { "v8/trace" };
     v8::ExtensionConfiguration config(1, extensions);
     env = v8::Context::New(&config);
   }
-  v8::HandleScope scope;
   env->Enter();
 }
 
@@ -283,7 +281,7 @@
   InitTraceEnv(&sample);
 
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   // Create global function JSFuncDoTrace which calls
   // extension function trace() with the current frame pointer value.
   CreateTraceCallerFunction("JSFuncDoTrace", "trace");
@@ -328,7 +326,7 @@
   InitTraceEnv(&sample);
 
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   // Create global function JSFuncDoTrace which calls
   // extension function js_trace() with the current frame pointer value.
   CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
@@ -402,7 +400,7 @@
 
 TEST(JsEntrySp) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   CHECK_EQ(0, GetJsEntrySp());
   CompileRun("a = 1; b = a + 1;");
   CHECK_EQ(0, GetJsEntrySp());
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index d75c219..53ccd3e 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -61,7 +61,7 @@
         temp_file_(NULL),
         // Need to run this prior to creating the scope.
         trick_to_run_init_flags_(init_flags_(prof_lazy)),
-        scope_(),
+        scope_(v8::Isolate::GetCurrent()),
         env_(v8::Context::New()) {
     env_->Enter();
   }
@@ -365,7 +365,7 @@
 }  // namespace
 
 TEST(Issue23768) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::Context> env = v8::Context::New();
   env->Enter();
 
diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc
index ab819b7..4640599 100644
--- a/test/cctest/test-mark-compact.cc
+++ b/test/cctest/test-mark-compact.cc
@@ -47,7 +47,6 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) env = v8::Context::New();
-  v8::HandleScope scope;
   env->Enter();
 }
 
@@ -92,7 +91,7 @@
 
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
 
   // Allocate a fixed array in the new space.
   int array_size =
@@ -120,7 +119,7 @@
   // the old space
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
 
   // Do a mark compact GC to shrink the heap.
   HEAP->CollectGarbage(OLD_POINTER_SPACE);
@@ -158,7 +157,7 @@
 TEST(MarkCompactCollector) {
   InitializeVM();
 
-  v8::HandleScope sc;
+  v8::HandleScope sc(env->GetIsolate());
   // call mark-compact when heap is empty
   HEAP->CollectGarbage(OLD_POINTER_SPACE);
 
@@ -320,7 +319,7 @@
   GlobalHandles* global_handles = Isolate::Current()->global_handles();
 
   NumberOfWeakCalls = 0;
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(env->GetIsolate());
 
   Handle<Object> g1s1 =
       global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
@@ -456,7 +455,7 @@
   InitializeVM();
   GlobalHandles* global_handles = Isolate::Current()->global_handles();
 
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(env->GetIsolate());
 
   Handle<Object> object =
       global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
diff --git a/test/cctest/test-object-observe.cc b/test/cctest/test-object-observe.cc
index 7fc5bf7..49007ba 100644
--- a/test/cctest/test-object-observe.cc
+++ b/test/cctest/test-object-observe.cc
@@ -47,6 +47,8 @@
     isolate_->Dispose();
   }
 
+  Isolate* GetIsolate() const { return isolate_; }
+
  private:
   Isolate* isolate_;
 };
@@ -54,7 +56,7 @@
 
 TEST(PerIsolateState) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context1;
   CompileRun(
       "var count = 0;"
@@ -94,7 +96,7 @@
 
 TEST(EndOfMicrotaskDelivery) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   CompileRun(
       "var obj = {};"
@@ -107,7 +109,7 @@
 
 TEST(DeliveryOrdering) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   CompileRun(
       "var obj1 = {};"
@@ -138,7 +140,7 @@
 
 TEST(DeliveryOrderingReentrant) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   CompileRun(
       "var obj = {};"
@@ -169,7 +171,7 @@
 
 TEST(DeliveryOrderingDeliverChangeRecords) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   CompileRun(
       "var obj = {};"
@@ -193,7 +195,7 @@
 
 TEST(ObjectHashTableGrowth) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   // Initializing this context sets up initial hash tables.
   LocalContext context;
   Handle<Value> obj = CompileRun("obj = {};");
@@ -222,8 +224,8 @@
 
 TEST(GlobalObjectObservation) {
   HarmonyIsolate isolate;
-  HandleScope scope;
   LocalContext context;
+  HandleScope scope(isolate.GetIsolate());
   Handle<Object> global_proxy = context->Global();
   Handle<Object> inner_global = global_proxy->GetPrototype().As<Object>();
   CompileRun(
@@ -317,7 +319,7 @@
 
 TEST(APITestBasicMutation) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   Handle<Object> obj = Handle<Object>::Cast(CompileRun(
       "var records = [];"
@@ -360,7 +362,7 @@
 
 TEST(HiddenPrototypeObservation) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   Handle<FunctionTemplate> tmpl = FunctionTemplate::New();
   tmpl->SetHiddenPrototype(true);
@@ -409,7 +411,7 @@
 
 TEST(ObservationWeakMap) {
   HarmonyIsolate isolate;
-  HandleScope scope;
+  HandleScope scope(isolate.GetIsolate());
   LocalContext context;
   CompileRun(
       "var obj = {};"
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index e99b5f2..c8956c9 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -173,7 +173,7 @@
 
 
 TEST(Preparsing) {
-  v8::HandleScope handles;
+  v8::HandleScope handles(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> context = v8::Context::New();
   v8::Context::Scope context_scope(context);
   int marker;
@@ -351,7 +351,7 @@
       "try { } catch (e) { var foo = function () { /* first */ } }"
       "var bar = function () { /* second */ }";
 
-  v8::HandleScope handles;
+  v8::HandleScope handles(v8::Isolate::GetCurrent());
   i::Handle<i::String> source(
       FACTORY->NewStringFromAscii(i::CStrVector(program)));
   i::GenericStringUtf16CharacterStream stream(source, 0, source->length());
@@ -544,7 +544,7 @@
 
 
 TEST(CharacterStreams) {
-  v8::HandleScope handles;
+  v8::HandleScope handles(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> context = v8::Context::New();
   v8::Context::Scope context_scope(context);
 
@@ -988,7 +988,7 @@
     { NULL, NULL, NULL, i::EVAL_SCOPE, i::CLASSIC_MODE }
   };
 
-  v8::HandleScope handles;
+  v8::HandleScope handles(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> context = v8::Context::New();
   v8::Context::Scope context_scope(context);
 
@@ -1226,7 +1226,7 @@
     NULL
   };
 
-  v8::HandleScope handles;
+  v8::HandleScope handles(v8::Isolate::GetCurrent());
   v8::Persistent<v8::Context> context = v8::Context::New();
   v8::Context::Scope context_scope(context);
 
@@ -1267,7 +1267,7 @@
   // such (issue 2220).
   v8::internal::FLAG_min_preparse_length = 1;  // Force preparsing.
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Context::Scope context_scope(v8::Context::New());
   v8::TryCatch try_catch;
   const char* script =
diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc
index 5ea0c52..22b4e05 100644
--- a/test/cctest/test-profile-generator.cc
+++ b/test/cctest/test-profile-generator.cc
@@ -61,7 +61,7 @@
 TEST(TokenEnumerator) {
   TokenEnumerator te;
   CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL));
-  v8::HandleScope hs;
+  v8::HandleScope hs(v8::Isolate::GetCurrent());
   v8::Local<v8::String> token1(v8::String::New("1x"));
   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
@@ -70,7 +70,7 @@
   CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
   CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
   {
-    v8::HandleScope hs;
+    v8::HandleScope hs(v8::Isolate::GetCurrent());
     v8::Local<v8::String> token3(v8::String::New("3x"));
     CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3)));
     CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2)));
@@ -784,12 +784,12 @@
   i::FLAG_use_inlining = false;
 
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     const char* extensions[] = { "v8/profiler" };
     v8::ExtensionConfiguration config(1, extensions);
     env = v8::Context::New(&config);
   }
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   env->Enter();
 
   CHECK_EQ(0, CpuProfiler::GetProfilesCount());
diff --git a/test/cctest/test-random.cc b/test/cctest/test-random.cc
index 32b626e..9394fc9 100644
--- a/test/cctest/test-random.cc
+++ b/test/cctest/test-random.cc
@@ -73,7 +73,7 @@
   if (env.IsEmpty()) env = v8::Context::New();
   // Skip test if crankshaft is disabled.
   if (!V8::UseCrankshaft()) return;
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   env->Enter();
 
   Handle<Context> context(Isolate::Current()->context());
diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc
index 1a65c06..c4175cb 100644
--- a/test/cctest/test-regexp.cc
+++ b/test/cctest/test-regexp.cc
@@ -71,7 +71,7 @@
 
 static bool CheckParse(const char* input) {
   V8::Initialize(NULL);
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   FlatStringReader reader(Isolate::Current(), CStrVector(input));
   RegExpCompileData result;
@@ -82,7 +82,7 @@
 
 static SmartArrayPointer<const char> Parse(const char* input) {
   V8::Initialize(NULL);
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   FlatStringReader reader(Isolate::Current(), CStrVector(input));
   RegExpCompileData result;
@@ -97,7 +97,7 @@
 
 static bool CheckSimple(const char* input) {
   V8::Initialize(NULL);
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   FlatStringReader reader(Isolate::Current(), CStrVector(input));
   RegExpCompileData result;
@@ -115,7 +115,7 @@
 
 static MinMaxPair CheckMinMaxMatch(const char* input) {
   V8::Initialize(NULL);
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   FlatStringReader reader(Isolate::Current(), CStrVector(input));
   RegExpCompileData result;
@@ -388,7 +388,7 @@
 static void ExpectError(const char* input,
                         const char* expected) {
   V8::Initialize(NULL);
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   FlatStringReader reader(Isolate::Current(), CStrVector(input));
   RegExpCompileData result;
@@ -530,7 +530,7 @@
                     bool multiline,
                     bool is_ascii,
                     bool dot_output = false) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   ZoneScope zone_scope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   RegExpNode* node = Compile(input, multiline, is_ascii);
   USE(node);
@@ -707,8 +707,9 @@
 class ContextInitializer {
  public:
   ContextInitializer()
-      : env_(), scope_(), zone_(Isolate::Current()->runtime_zone(),
-                                DELETE_ON_EXIT) {
+      : env_(),
+        scope_(v8::Isolate::GetCurrent()),
+        zone_(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT) {
     env_ = v8::Context::New();
     env_->Enter();
   }
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index b07db0f..777c769 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -282,7 +282,7 @@
 
 
 static void SanityCheck() {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
 #ifdef VERIFY_HEAP
   HEAP->Verify();
 #endif
@@ -299,7 +299,7 @@
   // serialization.  That doesn't matter.  We don't need to be able to
   // serialize a snapshot in a VM that is booted from a snapshot.
   if (!Snapshot::HaveASnapshotToStartFrom()) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     Deserialize();
 
     v8::Persistent<v8::Context> env = v8::Context::New();
@@ -312,7 +312,7 @@
 
 DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
   if (!Snapshot::HaveASnapshotToStartFrom()) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     Deserialize();
 
     v8::Persistent<v8::Context> env = v8::Context::New();
@@ -325,7 +325,7 @@
 
 DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
   if (!Snapshot::HaveASnapshotToStartFrom()) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     Deserialize();
 
     v8::Persistent<v8::Context> env = v8::Context::New();
@@ -342,7 +342,7 @@
 DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
                SerializeTwice) {
   if (!Snapshot::HaveASnapshotToStartFrom()) {
-    v8::HandleScope scope;
+    v8::HandleScope scope(v8::Isolate::GetCurrent());
     Deserialize();
 
     v8::Persistent<v8::Context> env = v8::Context::New();
@@ -377,7 +377,7 @@
 
     Object* raw_foo;
     {
-      v8::HandleScope handle_scope;
+      v8::HandleScope handle_scope(env->GetIsolate());
       v8::Local<v8::String> foo = v8::String::New("foo");
       ASSERT(!foo.IsEmpty());
       raw_foo = *(v8::Utils::OpenHandle(*foo));
@@ -473,7 +473,7 @@
       deserializer.DeserializePartial(&root);
       CHECK(root->IsString());
     }
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
     Handle<Object> root_handle(root, Isolate::Current());
 
 
@@ -571,7 +571,7 @@
       deserializer.DeserializePartial(&root);
       CHECK(root->IsContext());
     }
-    v8::HandleScope handle_scope;
+    v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
     Handle<Object> root_handle(root, Isolate::Current());
 
 
diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc
index c232b07..f240e93 100644
--- a/test/cctest/test-strings.cc
+++ b/test/cctest/test-strings.cc
@@ -100,7 +100,6 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
     const char* extensions[] = { "v8/print" };
     v8::ExtensionConfiguration config(1, extensions);
     env = v8::Context::New(&config);
@@ -576,7 +575,7 @@
 TEST(Traverse) {
   printf("TestTraverse\n");
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   ZoneScope zone(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
   ConsStringGenerationData data(false);
   Handle<String> flat = ConstructBalanced(&data);
@@ -865,7 +864,7 @@
 TEST(DeepAscii) {
   printf("TestDeepAscii\n");
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
 
   char* foo = NewArray<char>(DEEP_ASCII_DEPTH);
   for (int i = 0; i < DEEP_ASCII_DEPTH; i++) {
@@ -890,7 +889,7 @@
 TEST(Utf8Conversion) {
   // Smoke test for converting strings to utf-8.
   InitializeVM();
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(env->GetIsolate());
   // A simple ascii string
   const char* ascii_string = "abcdef12345";
   int len =
@@ -937,7 +936,7 @@
   ZoneScope zonescope(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT);
 
   InitializeVM();
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(env->GetIsolate());
   Zone* zone = Isolate::Current()->runtime_zone();
 
   // Make sure we cover all always-flat lengths and at least one above.
@@ -1029,7 +1028,7 @@
   ZoneScope zone(isolate->runtime_zone(), DELETE_ON_EXIT);
 
   InitializeVM();
-  v8::HandleScope handle_scope;
+  v8::HandleScope handle_scope(env->GetIsolate());
   // Lines must be executed sequentially. Combining them into one script
   // makes the bug go away.
   const char* lines[] = {
@@ -1072,7 +1071,7 @@
 TEST(SliceFromCons) {
   FLAG_string_slices = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   Handle<String> string =
       FACTORY->NewStringFromAscii(CStrVector("parentparentparent"));
   Handle<String> parent = FACTORY->NewConsString(string, string);
@@ -1104,7 +1103,7 @@
 TEST(SliceFromExternal) {
   FLAG_string_slices = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   AsciiVectorResource resource(
       i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
   Handle<String> string = FACTORY->NewExternalStringFromAscii(&resource);
@@ -1123,7 +1122,7 @@
   // actually creates a new string (it should not).
   FLAG_string_slices = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> result;
   Handle<String> string;
   const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
@@ -1152,7 +1151,7 @@
   // actually creates a new string (it should not).
   FLAG_string_slices = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> result;
   Handle<String> string;
   const char* init = "var str = 'abcdefghijklmnopqrstuvwxyz';";
@@ -1196,7 +1195,7 @@
       "for (var i = 1; i <= two_14; i++) a.push(s);"
       "a.join("");";
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   LocalContext context;
   v8::V8::IgnoreOutOfMemoryException();
   v8::Local<v8::Script> script =
@@ -1220,7 +1219,7 @@
   // If not recognized, those unsafe arguments lead to out-of-bounds reads.
   FLAG_allow_natives_syntax = true;
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   v8::Local<v8::Value> result;
   Handle<String> string;
   CompileRun("var short = 'abcdef';");
@@ -1264,7 +1263,7 @@
 TEST(RegExpOverflow) {
   // Result string has the length 2^32, causing a 32-bit integer overflow.
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   LocalContext context;
   v8::V8::IgnoreOutOfMemoryException();
   v8::Local<v8::Value> result = CompileRun(
@@ -1280,7 +1279,7 @@
 
 TEST(StringReplaceAtomTwoByteResult) {
   InitializeVM();
-  v8::HandleScope scope;
+  v8::HandleScope scope(env->GetIsolate());
   LocalContext context;
   v8::Local<v8::Value> result = CompileRun(
       "var subject = 'ascii~only~string~'; "
@@ -1302,7 +1301,6 @@
 
 
 
-#ifdef ENABLE_LATIN_1
 template<typename Op, bool return_first>
 static uint16_t ConvertLatin1(uint16_t c) {
   uint32_t result[Op::kMaxWidth];
@@ -1325,7 +1323,6 @@
 
 
 TEST(Latin1IgnoreCase) {
-  if (true) return;
   using namespace unibrow;
   for (uint16_t c = Latin1::kMaxChar + 1; c != 0; c++) {
     uint16_t lower = ConvertLatin1<ToLowercase, false>(c);
@@ -1357,4 +1354,3 @@
     CHECK_EQ(Min(upper, lower), test);
   }
 }
-#endif  // ENABLE_LATIN_1
diff --git a/test/cctest/test-symbols.cc b/test/cctest/test-symbols.cc
index adc100d..e953457 100644
--- a/test/cctest/test-symbols.cc
+++ b/test/cctest/test-symbols.cc
@@ -16,12 +16,10 @@
 
 static void InitializeVM() {
   if (env.IsEmpty()) {
-    v8::HandleScope scope;
     const char* extensions[] = { "v8/print" };
     v8::ExtensionConfiguration config(1, extensions);
     env = v8::Context::New(&config);
   }
-  v8::HandleScope scope;
   env->Enter();
 }
 
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc
index b249c7a..190fc7b 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -121,7 +121,7 @@
 // Test that a single thread of JavaScript execution can terminate
 // itself.
 TEST(TerminateOnlyV8ThreadFromThreadItself) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global =
       CreateGlobalTemplate(TerminateCurrentThread, DoLoop);
   v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
@@ -141,7 +141,7 @@
 // Test that a single thread of JavaScript execution can terminate
 // itself in a loop that performs no calls.
 TEST(TerminateOnlyV8ThreadFromThreadItselfNoLoop) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global =
       CreateGlobalTemplate(TerminateCurrentThread, DoLoopNoCall);
   v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
@@ -181,7 +181,7 @@
   TerminatorThread thread(i::Isolate::Current());
   thread.Start();
 
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global = CreateGlobalTemplate(Signal, DoLoop);
   v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
   v8::Context::Scope context_scope(context);
@@ -203,7 +203,7 @@
   LoopingThread() : Thread("LoopingThread") { }
   void Run() {
     v8::Locker locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(CcTest::default_isolate());
     v8_thread_id_ = v8::V8::GetCurrentThreadId();
     v8::Handle<v8::ObjectTemplate> global =
         CreateGlobalTemplate(Signal, DoLoop);
@@ -306,7 +306,7 @@
 // Test that we correctly handle termination exceptions if they are
 // triggered by the creation of error objects in connection with ICs.
 TEST(TerminateLoadICException) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
   global->Set(v8::String::New("terminate_or_return_object"),
               v8::FunctionTemplate::New(TerminateOrReturnObject));
@@ -357,7 +357,7 @@
 // Test that reentry into V8 while the termination exception is still pending
 // (has not yet unwound the 0-level JS frame) does not crash.
 TEST(TerminateAndReenterFromThreadItself) {
-  v8::HandleScope scope;
+  v8::HandleScope scope(v8::Isolate::GetCurrent());
   v8::Handle<v8::ObjectTemplate> global =
       CreateGlobalTemplate(TerminateCurrentThread, ReenterAfterTermination);
   v8::Persistent<v8::Context> context = v8::Context::New(NULL, global);
diff --git a/test/cctest/test-threads.cc b/test/cctest/test-threads.cc
index ffb29cd..5a010a8 100644
--- a/test/cctest/test-threads.cc
+++ b/test/cctest/test-threads.cc
@@ -36,7 +36,7 @@
 TEST(Preemption) {
   v8::Locker locker(CcTest::default_isolate());
   v8::V8::Initialize();
-  v8::HandleScope scope;
+  v8::HandleScope scope(CcTest::default_isolate());
   v8::Context::Scope context_scope(v8::Context::New());
 
   v8::Locker::StartPreemption(100);
@@ -68,7 +68,7 @@
   ThreadA() : Thread("ThreadA") { }
   void Run() {
     v8::Locker locker(CcTest::default_isolate());
-    v8::HandleScope scope;
+    v8::HandleScope scope(CcTest::default_isolate());
     v8::Context::Scope context_scope(v8::Context::New());
 
     CHECK_EQ(FILL_CACHE, turn);
@@ -107,7 +107,7 @@
       {
         v8::Locker locker(CcTest::default_isolate());
         if (turn == CLEAN_CACHE) {
-          v8::HandleScope scope;
+          v8::HandleScope scope(CcTest::default_isolate());
           v8::Context::Scope context_scope(v8::Context::New());
 
           // Clear the caches by forcing major GC.
diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc
index 714c8cc..1dd43a8 100644
--- a/test/cctest/test-weakmaps.cc
+++ b/test/cctest/test-weakmaps.cc
@@ -79,14 +79,14 @@
   Isolate* isolate = GetIsolateFrom(&context);
   Factory* factory = isolate->factory();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
   GlobalHandles* global_handles = isolate->global_handles();
 
   // Keep global reference to the key.
   Handle<Object> key;
   {
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
     Handle<JSObject> object = factory->NewJSObjectFromMap(map);
     key = global_handles->Create(*object);
@@ -95,7 +95,7 @@
 
   // Put entry into weak map.
   {
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     PutIntoWeakMap(weakmap,
                    Handle<JSObject>(JSObject::cast(*key)),
                    Handle<Smi>(Smi::FromInt(23), isolate));
@@ -111,7 +111,7 @@
 
   // Make the global reference to the key weak.
   {
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     global_handles->MakeWeak(key.location(),
                              reinterpret_cast<void*>(1234),
                              NULL,
@@ -140,7 +140,7 @@
   Isolate* isolate = GetIsolateFrom(&context);
   Factory* factory = isolate->factory();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   Handle<JSWeakMap> weakmap = AllocateJSWeakMap(isolate);
 
   // Check initial capacity.
@@ -148,7 +148,7 @@
 
   // Fill up weak map to trigger capacity change.
   {
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
     for (int i = 0; i < 32; i++) {
       Handle<JSObject> object = factory->NewJSObjectFromMap(map);
@@ -181,7 +181,7 @@
   Isolate* isolate = GetIsolateFrom(&context);
   Factory* factory = isolate->factory();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   Handle<JSFunction> function =
       factory->NewFunction(factory->function_string(), factory->null_value());
   Handle<JSObject> key = factory->NewJSObject(function);
@@ -193,7 +193,7 @@
 
   // Fill up weak map with values on an evacuation candidate.
   {
-    v8::HandleScope scope;
+    HandleScope scope(isolate);
     for (int i = 0; i < 32; i++) {
       Handle<JSObject> object = factory->NewJSObject(function, TENURED);
       CHECK(!heap->InNewSpace(object->address()));
@@ -220,7 +220,7 @@
   Isolate* isolate = GetIsolateFrom(&context);
   Factory* factory = isolate->factory();
   Heap* heap = isolate->heap();
-  v8::HandleScope scope;
+  HandleScope scope(isolate);
   Handle<JSFunction> function =
       factory->NewFunction(factory->function_string(), factory->null_value());
 
diff --git a/test/mjsunit/compiler/inline-literals.js b/test/mjsunit/compiler/inline-literals.js
index 1422586..4487996 100644
--- a/test/mjsunit/compiler/inline-literals.js
+++ b/test/mjsunit/compiler/inline-literals.js
@@ -87,3 +87,24 @@
 %OptimizeFunctionOnNextCall(TestRegExpLiteral);
 TestRegExpLiteral("ab", "reg", "exp", "regexpexpreg");
 TestRegExpLiteral("ab", 12345, 54321, "6666666666");
+
+function f2(b, c) {
+  var closure = function(b, c) { return b + c; }
+  var value = b + c;
+  return closure;
+}
+
+function f1(a, b, c) {
+  return a + f2(b, c)(b, c);
+}
+
+function TestFunctionLiteral(a, b, c, expected) {
+  var result = f1(a, b, c);
+  assertEquals(expected, result, "TestFunctionLiteral");
+}
+
+TestFunctionLiteral(1, 2, 3, 6);
+TestFunctionLiteral(4, 5, 6, 15);
+%OptimizeFunctionOnNextCall(TestFunctionLiteral);
+TestFunctionLiteral(7, 8, 9, 24);
+TestFunctionLiteral("a", "b", "c", "abc");