Revision: 22543
Author: [email protected]
Date: Wed Jul 23 08:27:04 2014 UTC
Log: Fix debugger-related issues in the code serializer.
[email protected]
Review URL: https://codereview.chromium.org/410883003
http://code.google.com/p/v8/source/detail?r=22543
Modified:
/branches/bleeding_edge/src/compiler.cc
/branches/bleeding_edge/src/debug.cc
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/serialize.cc
=======================================
--- /branches/bleeding_edge/src/compiler.cc Tue Jul 22 10:35:38 2014 UTC
+++ /branches/bleeding_edge/src/compiler.cc Wed Jul 23 08:27:04 2014 UTC
@@ -961,7 +961,8 @@
Handle<SharedFunctionInfo> result;
if (extension == NULL) {
if (FLAG_serialize_toplevel &&
- compile_options == ScriptCompiler::kConsumeCodeCache) {
+ compile_options == ScriptCompiler::kConsumeCodeCache &&
+ !isolate->debug()->is_loaded()) {
return CodeSerializer::Deserialize(isolate, *cached_data, source);
} else {
maybe_result = compilation_cache->LookupScript(
=======================================
--- /branches/bleeding_edge/src/debug.cc Tue Jul 22 08:28:49 2014 UTC
+++ /branches/bleeding_edge/src/debug.cc Wed Jul 23 08:27:04 2014 UTC
@@ -622,7 +622,14 @@
HashMap::Entry* entry =
HashMap::Lookup(reinterpret_cast<void*>(id), Hash(id), true);
if (entry->value != NULL) {
- ASSERT(*script == *reinterpret_cast<Script**>(entry->value));
+#ifdef DEBUG
+ // The code deserializer may introduce duplicate Script objects.
+ // Assert that the Script objects with the same id have the same name.
+ Handle<Script> found(reinterpret_cast<Script**>(entry->value));
+ ASSERT(script->id() == found->id());
+ ASSERT(!script->name()->IsString() ||
+
String::cast(script->name())->Equals(String::cast(found->name())));
+#endif
return;
}
// Globalize the script object, make it weak and use the location of the
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Jul 22 09:44:56 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Wed Jul 23 08:27:04 2014 UTC
@@ -10284,16 +10284,21 @@
// collector will call the weak callback on the global handle
// associated with the wrapper and get rid of both the wrapper and the
// handle.
-static void ClearWrapperCache(
+static void ClearWrapperCacheWeakCallback(
const v8::WeakCallbackData<v8::Value, void>& data) {
Object** location = reinterpret_cast<Object**>(data.GetParameter());
JSValue* wrapper = JSValue::cast(*location);
- Foreign* foreign = Script::cast(wrapper->value())->wrapper();
+ Script::cast(wrapper->value())->ClearWrapperCache();
+}
+
+
+void Script::ClearWrapperCache() {
+ Foreign* foreign = wrapper();
+ Object** location =
reinterpret_cast<Object**>(foreign->foreign_address());
ASSERT_EQ(foreign->foreign_address(),
reinterpret_cast<Address>(location));
foreign->set_foreign_address(0);
GlobalHandles::Destroy(location);
- Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
- isolate->counters()->script_wrappers()->Decrement();
+ GetIsolate()->counters()->script_wrappers()->Decrement();
}
@@ -10318,7 +10323,7 @@
Handle<Object> handle = isolate->global_handles()->Create(*result);
GlobalHandles::MakeWeak(handle.location(),
reinterpret_cast<void*>(handle.location()),
- &ClearWrapperCache);
+ &ClearWrapperCacheWeakCallback);
script->wrapper()->set_foreign_address(
reinterpret_cast<Address>(handle.location()));
return result;
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Jul 23 07:16:32 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Wed Jul 23 08:27:04 2014 UTC
@@ -6934,6 +6934,7 @@
// Get the JS object wrapping the given script; create it if none exists.
static Handle<JSObject> GetWrapper(Handle<Script> script);
+ void ClearWrapperCache();
// Dispatched behavior.
DECLARE_PRINTER(Script)
=======================================
--- /branches/bleeding_edge/src/serialize.cc Wed Jul 23 07:16:32 2014 UTC
+++ /branches/bleeding_edge/src/serialize.cc Wed Jul 23 08:27:04 2014 UTC
@@ -1961,6 +1961,13 @@
SerializeSourceObject(how_to_code, where_to_point, skip);
return;
}
+
+ if (heap_object->IsScript()) {
+ // The wrapper cache uses a Foreign object to point to a global handle.
+ // However, the object visitor expects foreign objects to point to
external
+ // references. Clear the cache to avoid this issue.
+ Script::cast(heap_object)->ClearWrapperCache();
+ }
if (skip != 0) {
sink_->Put(kSkip, "SkipFromSerializeObject");
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.