Revision: 14635
Author:   [email protected]
Date:     Mon May 13 03:59:00 2013
Log:      Prevent flushing of code that was set with %SetCode.

This makes sure that shared function infos that break the one-to-one
mapping to code are marked as un-flushable. Otherwise enqueuing through
the GC meta-data field in the code object doesn't work.

[email protected]
TEST=cctest/test-api/Threading4

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

Modified:
 /branches/bleeding_edge/src/bootstrapper.cc
 /branches/bleeding_edge/src/objects-inl.h
 /branches/bleeding_edge/src/objects-visiting-inl.h
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/v8natives.js

=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Mon May 13 00:35:26 2013
+++ /branches/bleeding_edge/src/bootstrapper.cc Mon May 13 03:59:00 2013
@@ -455,9 +455,8 @@
function_map_writable_prototype_ = CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);

   Factory* factory = isolate->factory();
-  Heap* heap = isolate->heap();

-  Handle<String> object_name = Handle<String>(heap->Object_string());
+  Handle<String> object_name = factory->Object_string();

   {  // --- O b j e c t ---
     Handle<JSFunction> object_fun =
@@ -834,7 +833,7 @@
   Factory* factory = isolate->factory();
   Heap* heap = isolate->heap();

-  Handle<String> object_name = Handle<String>(heap->Object_string());
+  Handle<String> object_name = factory->Object_string();
   CHECK_NOT_EMPTY_HANDLE(isolate,
                          JSObject::SetLocalPropertyIgnoreAttributes(
                              inner_global, object_name,
=======================================
--- /branches/bleeding_edge/src/objects-inl.h   Fri May 10 10:17:50 2013
+++ /branches/bleeding_edge/src/objects-inl.h   Mon May 13 03:59:00 2013
@@ -4672,6 +4672,7 @@
                kDontOptimize)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_inline, kDontInline)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_cache, kDontCache)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_generator, kIsGenerator)

 void SharedFunctionInfo::BeforeVisitingPointers() {
=======================================
--- /branches/bleeding_edge/src/objects-visiting-inl.h Tue May 7 08:18:01 2013 +++ /branches/bleeding_edge/src/objects-visiting-inl.h Mon May 13 03:59:00 2013
@@ -566,14 +566,14 @@
     return false;
   }

- // If this is a full script wrapped in a function we do no flush the code. + // If this is a full script wrapped in a function we do not flush the code.
   if (shared_info->is_toplevel()) {
     return false;
   }

-  // If this is a native function we do not flush the code because %SetCode
-  // breaks the one-to-one relation between SharedFunctionInfo and Code.
-  if (shared_info->native()) {
+  // If this is a function initialized with %SetCode then the one-to-one
+  // relation between SharedFunctionInfo and Code is broken.
+  if (shared_info->dont_flush()) {
     return false;
   }

=======================================
--- /branches/bleeding_edge/src/objects.h       Mon May 13 00:35:26 2013
+++ /branches/bleeding_edge/src/objects.h       Mon May 13 03:59:00 2013
@@ -6125,6 +6125,9 @@
   // Indicates that code for this function cannot be cached.
   DECL_BOOLEAN_ACCESSORS(dont_cache)

+  // Indicates that code for this function cannot be flushed.
+  DECL_BOOLEAN_ACCESSORS(dont_flush)
+
   // Indicates that this function is a generator.
   DECL_BOOLEAN_ACCESSORS(is_generator)

@@ -6354,6 +6357,7 @@
     kDontOptimize,
     kDontInline,
     kDontCache,
+    kDontFlush,
     kIsGenerator,
     kCompilerHintsCount  // Pseudo entry
   };
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri May 10 05:59:20 2013
+++ /branches/bleeding_edge/src/runtime.cc      Mon May 13 03:59:00 2013
@@ -2497,6 +2497,13 @@
   if (!JSFunction::EnsureCompiled(source, KEEP_EXCEPTION)) {
     return Failure::Exception();
   }
+
+  // Mark both, the source and the target, as un-flushable because the
+  // shared unoptimized code makes them impossible to enqueue in a list.
+  ASSERT(target_shared->code()->gc_metadata() == NULL);
+  ASSERT(source_shared->code()->gc_metadata() == NULL);
+  target_shared->set_dont_flush(true);
+  source_shared->set_dont_flush(true);

   // Set the code, scope info, formal parameter count, and the length
   // of the target shared function info.  Set the source code of the
=======================================
--- /branches/bleeding_edge/src/v8natives.js    Fri May 10 05:59:20 2013
+++ /branches/bleeding_edge/src/v8natives.js    Mon May 13 03:59:00 2013
@@ -1356,6 +1356,7 @@
 function SetUpObject() {
   %CheckIsBootstrapping();

+  %SetNativeFlag($Object);
   %SetCode($Object, ObjectConstructor);
   %FunctionSetName(ObjectPoisonProto, "__proto__");
   %FunctionRemovePrototype(ObjectPoisonProto);

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


Reply via email to