deps: upgrade v8 to 4.2.77.20
authorBen Noordhuis <info@bnoordhuis.nl>
Wed, 6 May 2015 15:04:07 +0000 (17:04 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Wed, 6 May 2015 18:14:07 +0000 (20:14 +0200)
Fixes: https://github.com/iojs/io.js/issues/1637
PR-URL: https://github.com/iojs/io.js/pull/1639
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
V8-Bug: https://code.google.com/p/v8/issues/detail?id=3960
V8-Bug: https://code.google.com/p/v8/issues/detail?id=4079

15 files changed:
deps/v8/include/v8-version.h
deps/v8/src/compiler.cc
deps/v8/src/compiler/graph-visualizer.h
deps/v8/src/debug.cc
deps/v8/src/factory.cc
deps/v8/src/heap/heap.h
deps/v8/src/liveedit.cc
deps/v8/src/runtime/runtime-debug.cc
deps/v8/src/runtime/runtime.h
deps/v8/src/serialize.cc
deps/v8/test/mjsunit/debug-breakpoints.js
deps/v8/test/mjsunit/debug-liveedit-2.js
deps/v8/test/mjsunit/debug-liveedit-4.js
deps/v8/test/mjsunit/deserialize-script-id.js [new file with mode: 0644]
deps/v8/test/mjsunit/regress/regress-2825.js

index 5f59b89..f10bf50 100644 (file)
@@ -11,7 +11,7 @@
 #define V8_MAJOR_VERSION 4
 #define V8_MINOR_VERSION 2
 #define V8_BUILD_NUMBER 77
-#define V8_PATCH_LEVEL 18
+#define V8_PATCH_LEVEL 20
 
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
index d794ae2..2bad9e6 100644 (file)
@@ -1455,7 +1455,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
   result->set_is_toplevel(false);
 
   RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
-  result->set_allows_lazy_compilation(allow_lazy);
+  result->set_allows_lazy_compilation(literal->AllowsLazyCompilation());
   result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
 
   // Set the expected number of properties for instances and return
index 17094c2..0e6a647 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef V8_COMPILER_GRAPH_VISUALIZER_H_
 #define V8_COMPILER_GRAPH_VISUALIZER_H_
 
+#include <stdio.h>
 #include <iosfwd>
 
 namespace v8 {
index 324d96f..a7bf765 100644 (file)
@@ -1604,23 +1604,22 @@ Handle<Object> Debug::GetSourceBreakLocations(
   Handle<FixedArray> locations =
       isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount());
   int count = 0;
-  for (int i = 0; i < debug_info->break_points()->length(); i++) {
+  for (int i = 0; i < debug_info->break_points()->length(); ++i) {
     if (!debug_info->break_points()->get(i)->IsUndefined()) {
       BreakPointInfo* break_point_info =
           BreakPointInfo::cast(debug_info->break_points()->get(i));
-      if (break_point_info->GetBreakPointCount() > 0) {
-        Smi* position = NULL;
-        switch (position_alignment) {
-          case STATEMENT_ALIGNED:
-            position = break_point_info->statement_position();
-            break;
-          case BREAK_POSITION_ALIGNED:
-            position = break_point_info->source_position();
-            break;
-        }
-
-        locations->set(count++, position);
+      int break_points = break_point_info->GetBreakPointCount();
+      if (break_points == 0) continue;
+      Smi* position = NULL;
+      switch (position_alignment) {
+        case STATEMENT_ALIGNED:
+          position = break_point_info->statement_position();
+          break;
+        case BREAK_POSITION_ALIGNED:
+          position = break_point_info->source_position();
+          break;
       }
+      for (int j = 0; j < break_points; ++j) locations->set(count++, position);
     }
   }
   return locations;
@@ -1923,7 +1922,6 @@ static void RecompileAndRelocateSuspendedGenerators(
 static bool SkipSharedFunctionInfo(SharedFunctionInfo* shared,
                                    Object* active_code_marker) {
   if (!shared->allows_lazy_compilation()) return true;
-  if (!shared->script()->IsScript()) return true;
   Object* script = shared->script();
   if (!script->IsScript()) return true;
   if (Script::cast(script)->type()->value() == Script::TYPE_NATIVE) return true;
@@ -2204,6 +2202,21 @@ Object* Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
     }
   }  // End while loop.
 
+  // JSFunctions from the same literal may not have the same shared function
+  // info. Find those JSFunctions and deduplicate the shared function info.
+  HeapIterator iterator(heap, FLAG_lazy ? HeapIterator::kNoFiltering
+                                        : HeapIterator::kFilterUnreachable);
+  for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
+    if (!obj->IsJSFunction()) continue;
+    JSFunction* function = JSFunction::cast(obj);
+    SharedFunctionInfo* shared = function->shared();
+    if (shared != *target && shared->script() == target->script() &&
+        shared->start_position_and_type() ==
+            target->start_position_and_type()) {
+      function->set_shared(*target);
+    }
+  }
+
   return *target;
 }
 
index a07d656..95590ad 100644 (file)
@@ -826,17 +826,12 @@ Handle<ExecutableAccessorInfo> Factory::NewExecutableAccessorInfo() {
 
 
 Handle<Script> Factory::NewScript(Handle<String> source) {
-  // Generate id for this script.
-  Heap* heap = isolate()->heap();
-  int id = heap->last_script_id()->value() + 1;
-  if (!Smi::IsValid(id) || id < 0) id = 1;
-  heap->set_last_script_id(Smi::FromInt(id));
-
   // Create and initialize script object.
+  Heap* heap = isolate()->heap();
   Handle<Script> script = Handle<Script>::cast(NewStruct(SCRIPT_TYPE));
   script->set_source(*source);
   script->set_name(heap->undefined_value());
-  script->set_id(Smi::FromInt(id));
+  script->set_id(isolate()->heap()->NextScriptId());
   script->set_line_offset(Smi::FromInt(0));
   script->set_column_offset(Smi::FromInt(0));
   script->set_context_data(heap->undefined_value());
index bd46216..21eb7e6 100644 (file)
@@ -1339,6 +1339,14 @@ class Heap {
     return seed;
   }
 
+  Smi* NextScriptId() {
+    int next_id = last_script_id()->value() + 1;
+    if (!Smi::IsValid(next_id) || next_id < 0) next_id = 1;
+    Smi* next_id_smi = Smi::FromInt(next_id);
+    set_last_script_id(next_id_smi);
+    return next_id_smi;
+  }
+
   void SetArgumentsAdaptorDeoptPCOffset(int pc_offset) {
     DCHECK(arguments_adaptor_deopt_pc_offset() == Smi::FromInt(0));
     set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset));
index 8da3d52..e880cab 100644 (file)
@@ -1238,6 +1238,7 @@ void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper,
       UnwrapSharedFunctionInfoFromJSValue(function_wrapper);
   CHECK(script_handle->IsScript() || script_handle->IsUndefined());
   shared_info->set_script(*script_handle);
+  shared_info->DisableOptimization(kLiveEdit);
 
   function_wrapper->GetIsolate()->compilation_cache()->Remove(shared_info);
 }
index f8c1238..563e808 100644 (file)
@@ -2327,6 +2327,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetLoadedScripts) {
   HandleScope scope(isolate);
   DCHECK(args.length() == 0);
 
+  DebugScope debug_scope(isolate->debug());
   // Fill the script objects.
   Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts();
 
@@ -2674,6 +2675,15 @@ RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) {
 }
 
 
+RUNTIME_FUNCTION(Runtime_GetDebugContext) {
+  HandleScope scope(isolate);
+  DCHECK(args.length() == 0);
+  Handle<Context> context = isolate->debug()->GetDebugContext();
+  context->set_security_token(isolate->native_context()->security_token());
+  return context->global_proxy();
+}
+
+
 // Performs a GC.
 // Presently, it only does a full GC.
 RUNTIME_FUNCTION(Runtime_CollectGarbage) {
index d277aee..12f7af4 100644 (file)
@@ -577,7 +577,7 @@ namespace internal {
   F(LiveEditRestartFrame, 2, 1)                     \
   F(GetFunctionCodePositionFromSource, 2, 1)        \
   F(ExecuteInDebugContext, 2, 1)                    \
-                                                    \
+  F(GetDebugContext, 0, 1)                          \
   F(SetFlags, 1, 1)                                 \
   F(CollectGarbage, 1, 1)                           \
   F(GetHeapUsage, 0, 1)
index 28480e6..8048f41 100644 (file)
@@ -820,6 +820,8 @@ HeapObject* Deserializer::ProcessNewObjectFromSerializedCode(HeapObject* obj) {
       string->SetForwardedInternalizedString(canonical);
       return canonical;
     }
+  } else if (obj->IsScript()) {
+    Script::cast(obj)->set_id(isolate_->heap()->NextScriptId());
   }
   return obj;
 }
index a04fac5..22c7ab5 100644 (file)
@@ -29,6 +29,8 @@
 // Get the Debug object exposed from the debug context global object.
 Debug = debug.Debug
 
+Debug.setListener(function() {});
+
 function f() {a=1;b=2}
 function g() {
   a=1;
index 39ebf3a..86aa7be 100644 (file)
@@ -25,7 +25,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// Flags: --expose-debug-as debug
+// Flags: --expose-debug-as debug --noalways-opt
 // Get the Debug object exposed from the debug context global object.
 
 
index 38f7514..6fc4137 100644 (file)
@@ -25,7 +25,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// Flags: --expose-debug-as debug
+// Flags: --expose-debug-as debug --noalways-opt
 // Get the Debug object exposed from the debug context global object.
 
 // In this test case we edit a script so that techincally function text
diff --git a/deps/v8/test/mjsunit/deserialize-script-id.js b/deps/v8/test/mjsunit/deserialize-script-id.js
new file mode 100644 (file)
index 0000000..ba54b46
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --cache=code
+// Test that script ids are unique and we found the correct ones.
+
+var scripts = %DebugGetLoadedScripts();
+scripts.sort(function(a, b) { return a.id - b.id; });
+var user_script_count = 0;
+scripts.reduce(function(prev, cur) {
+  assertTrue(prev === undefined || prev.id != cur.id);
+  if (cur.type == 2) user_script_count++;
+});
+
+// Found mjsunit.js and this script.
+assertEquals(2, user_script_count);
index 34348c9..6ffd8ec 100644 (file)
@@ -7,7 +7,7 @@
 // Do not edit this file with an editor that replaces \r with \r\n.
 // Variable definitions for i0 through i3 are each terminated with \r.
 function f() {
-  var i0 = 0;\r  var i1 = 1;\r  var i2 = 2;\r  var i3 = 3;
+  var i0 = 0;\r  var i1 = 1;\r  var i2 = 2;\r  var i3 = 3;\r
   var j0 = 0;
   var j1 = 1;
   var j2 = 2;