Revision: 7264
Author: [email protected]
Date: Fri Mar 18 07:48:51 2011
Log: [Isolates] Merge (7253,7263] from bleeding_edge.
r7263 | Make Script.prototype.nameOrSourceURL use indexOf search first
before trying to match with a RegExp.
r7262 | Revert r7258 and r7260.
r7261 | Fix presumbit warning after r7259
r7260 | Fix build.
r7259 | Dramatically speed up detailed heap snapshot generation.
r7258 | Make exception thrown via v8 public API propagate to
v8::TryCatch as JS thrown exceptions do.
Review URL: http://codereview.chromium.org/6711034
http://code.google.com/p/v8/source/detail?r=7264
Modified:
/branches/experimental/isolates/MERGE
/branches/experimental/isolates/src/messages.js
/branches/experimental/isolates/src/objects-inl.h
/branches/experimental/isolates/src/objects.h
/branches/experimental/isolates/src/profile-generator.cc
/branches/experimental/isolates/src/profile-generator.h
=======================================
--- /branches/experimental/isolates/MERGE Thu Mar 17 20:12:17 2011
+++ /branches/experimental/isolates/MERGE Fri Mar 18 07:48:51 2011
@@ -1,3 +1,3 @@
This file contains the bleeding_edge revision number to which we are
currently merged.
-7253
+7263
=======================================
--- /branches/experimental/isolates/src/messages.js Thu Mar 17 19:49:59 2011
+++ /branches/experimental/isolates/src/messages.js Fri Mar 18 07:48:51 2011
@@ -495,10 +495,24 @@
// because this file is being processed by js2c whose handling of spaces
// in regexps is broken. Also, ['"] are excluded from allowed URLs to
// avoid matches against sources that invoke evals with sourceURL.
- var sourceUrlPattern =
- /\/\/@[\040\t]sourceURL=[\040\t]*([^\s'"]*)[\040\t]*$/m;
- var match = sourceUrlPattern.exec(this.source);
- return match ? match[1] : this.name;
+ // A better solution would be to detect these special comments in
+ // the scanner/parser.
+ var source = ToString(this.source);
+ var sourceUrlPos = %StringIndexOf(source, "sourceURL=", 0);
+ if (sourceUrlPos > 4) {
+ var sourceUrlPattern =
+ /\/\/@[\040\t]sourceURL=[\040\t]*([^\s\'\"]*)[\040\t]*$/gm;
+ // Don't reuse lastMatchInfo here, so we create a new array with room
+ // for four captures (array with length one longer than the index
+ // of the fourth capture, where the numbering is zero-based).
+ var matchInfo = new InternalArray(CAPTURE(3) + 1);
+ var match =
+ %_RegExpExec(sourceUrlPattern, source, sourceUrlPos - 4,
matchInfo);
+ if (match) {
+ return SubString(source, matchInfo[CAPTURE(2)],
matchInfo[CAPTURE(3)]);
+ }
+ }
+ return this.name;
}
=======================================
--- /branches/experimental/isolates/src/objects-inl.h Fri Mar 11 19:15:52
2011
+++ /branches/experimental/isolates/src/objects-inl.h Fri Mar 18 07:48:51
2011
@@ -1362,6 +1362,12 @@
return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) -
map()->inobject_properties();
}
+
+
+int JSObject::GetInternalFieldOffset(int index) {
+ ASSERT(index < GetInternalFieldCount() && index >= 0);
+ return GetHeaderSize() + (kPointerSize * index);
+}
Object* JSObject::GetInternalField(int index) {
@@ -1413,6 +1419,14 @@
}
return value;
}
+
+
+int JSObject::GetInObjectPropertyOffset(int index) {
+ // Adjust for the number of properties stored in the object.
+ index -= map()->inobject_properties();
+ ASSERT(index < 0);
+ return map()->instance_size() + (index * kPointerSize);
+}
Object* JSObject::InObjectPropertyAt(int index) {
=======================================
--- /branches/experimental/isolates/src/objects.h Fri Mar 11 19:15:52 2011
+++ /branches/experimental/isolates/src/objects.h Fri Mar 18 07:48:51 2011
@@ -1596,6 +1596,7 @@
inline int GetHeaderSize();
inline int GetInternalFieldCount();
+ inline int GetInternalFieldOffset(int index);
inline Object* GetInternalField(int index);
inline void SetInternalField(int index, Object* value);
@@ -1713,6 +1714,7 @@
inline Object* FastPropertyAtPut(int index, Object* value);
// Access to in object properties.
+ inline int GetInObjectPropertyOffset(int index);
inline Object* InObjectPropertyAt(int index);
inline Object* InObjectPropertyAtPut(int index,
Object* value,
=======================================
--- /branches/experimental/isolates/src/profile-generator.cc Fri Mar 11
19:15:52 2011
+++ /branches/experimental/isolates/src/profile-generator.cc Fri Mar 18
07:48:51 2011
@@ -1830,25 +1830,40 @@
IndexedReferencesExtractor(V8HeapExplorer* generator,
HeapObject* parent_obj,
HeapEntry* parent_entry,
- HeapObjectsSet* known_references = NULL)
+ bool process_field_marks = false)
: generator_(generator),
parent_obj_(parent_obj),
parent_(parent_entry),
- known_references_(known_references),
+ process_field_marks_(process_field_marks),
next_index_(1) {
}
void VisitPointers(Object** start, Object** end) {
for (Object** p = start; p < end; p++) {
- if (!known_references_ || !known_references_->Contains(*p)) {
- generator_->SetHiddenReference(parent_obj_, parent_,
next_index_++, *p);
- }
+ if (CheckVisitedAndUnmark(p)) continue;
+ generator_->SetHiddenReference(parent_obj_, parent_, next_index_++,
*p);
}
}
+ static void MarkVisitedField(HeapObject* obj, int offset) {
+ if (offset < 0) return;
+ Address field = obj->address() + offset;
+ ASSERT(!Memory::Object_at(field)->IsFailure());
+ ASSERT(Memory::Object_at(field)->IsHeapObject());
+ *field |= kFailureTag;
+ }
private:
+ bool CheckVisitedAndUnmark(Object** field) {
+ if (process_field_marks_ && (*field)->IsFailure()) {
+ intptr_t untagged = reinterpret_cast<intptr_t>(*field) &
~kFailureTagMask;
+ *field = reinterpret_cast<Object*>(untagged | kHeapObjectTag);
+ ASSERT((*field)->IsHeapObject());
+ return true;
+ }
+ return false;
+ }
V8HeapExplorer* generator_;
HeapObject* parent_obj_;
HeapEntry* parent_;
- HeapObjectsSet* known_references_;
+ bool process_field_marks_;
int next_index_;
};
@@ -1857,7 +1872,6 @@
HeapEntry* entry = GetEntry(obj);
if (entry == NULL) return; // No interest in this object.
- known_references_.Clear();
if (obj->IsJSGlobalProxy()) {
// We need to reference JS global objects from snapshot's root.
// We use JSGlobalProxy because this is what embedder (e.g. browser)
@@ -1875,14 +1889,26 @@
SetPropertyReference(
obj, entry, HEAP->Proto_symbol(), js_obj->GetPrototype());
if (obj->IsJSFunction()) {
- JSFunction* js_fun = JSFunction::cast(obj);
- if (js_fun->has_prototype()) {
- SetPropertyReference(
- obj, entry, HEAP->prototype_symbol(), js_fun->prototype());
+ JSFunction* js_fun = JSFunction::cast(js_obj);
+ SetInternalReference(
+ js_fun, entry,
+ "code", js_fun->shared(),
+ JSFunction::kSharedFunctionInfoOffset);
+ Object* proto_or_map = js_fun->prototype_or_initial_map();
+ if (!proto_or_map->IsTheHole()) {
+ if (!proto_or_map->IsMap()) {
+ SetPropertyReference(
+ obj, entry,
+ HEAP->prototype_symbol(), proto_or_map,
+ JSFunction::kPrototypeOrInitialMapOffset);
+ } else {
+ SetPropertyReference(
+ obj, entry,
+ HEAP->prototype_symbol(), js_fun->prototype());
+ }
}
}
- IndexedReferencesExtractor refs_extractor(
- this, obj, entry, &known_references_);
+ IndexedReferencesExtractor refs_extractor(this, obj, entry, true);
obj->Iterate(&refs_extractor);
} else if (obj->IsString()) {
if (obj->IsConsString()) {
@@ -1915,7 +1941,6 @@
SetClosureReference(js_obj, entry, local_name, context->get(idx));
}
}
- SetInternalReference(js_obj, entry, "code", func->shared());
}
}
@@ -1928,13 +1953,22 @@
switch (descs->GetType(i)) {
case FIELD: {
int index = descs->GetFieldIndex(i);
- SetPropertyReference(
- js_obj, entry, descs->GetKey(i),
js_obj->FastPropertyAt(index));
+ if (index < js_obj->map()->inobject_properties()) {
+ SetPropertyReference(
+ js_obj, entry,
+ descs->GetKey(i), js_obj->InObjectPropertyAt(index),
+ js_obj->GetInObjectPropertyOffset(index));
+ } else {
+ SetPropertyReference(
+ js_obj, entry,
+ descs->GetKey(i), js_obj->FastPropertyAt(index));
+ }
break;
}
case CONSTANT_FUNCTION:
SetPropertyReference(
- js_obj, entry, descs->GetKey(i),
descs->GetConstantFunction(i));
+ js_obj, entry,
+ descs->GetKey(i), descs->GetConstantFunction(i));
break;
default: ;
}
@@ -1994,7 +2028,8 @@
int length = js_obj->GetInternalFieldCount();
for (int i = 0; i < length; ++i) {
Object* o = js_obj->GetInternalField(i);
- SetInternalReference(js_obj, entry, i, o);
+ SetInternalReference(
+ js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i));
}
}
@@ -2056,7 +2091,6 @@
collection_->names()->GetName(reference_name),
child_obj,
child_entry);
- known_references_.Insert(child_obj);
}
}
@@ -2073,7 +2107,6 @@
index,
child_obj,
child_entry);
- known_references_.Insert(child_obj);
}
}
@@ -2081,7 +2114,8 @@
void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
HeapEntry* parent_entry,
const char* reference_name,
- Object* child_obj) {
+ Object* child_obj,
+ int field_offset) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry != NULL) {
filler_->SetNamedReference(HeapGraphEdge::kInternal,
@@ -2090,7 +2124,7 @@
reference_name,
child_obj,
child_entry);
- known_references_.Insert(child_obj);
+ IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
}
}
@@ -2098,7 +2132,8 @@
void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
HeapEntry* parent_entry,
int index,
- Object* child_obj) {
+ Object* child_obj,
+ int field_offset) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry != NULL) {
filler_->SetNamedReference(HeapGraphEdge::kInternal,
@@ -2107,7 +2142,7 @@
collection_->names()->GetName(index),
child_obj,
child_entry);
- known_references_.Insert(child_obj);
+ IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
}
}
@@ -2131,7 +2166,8 @@
void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj,
HeapEntry* parent_entry,
String* reference_name,
- Object* child_obj) {
+ Object* child_obj,
+ int field_offset) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry != NULL) {
HeapGraphEdge::Type type = reference_name->length() > 0 ?
@@ -2142,16 +2178,15 @@
collection_->names()->GetName(reference_name),
child_obj,
child_entry);
- known_references_.Insert(child_obj);
+ IndexedReferencesExtractor::MarkVisitedField(parent_obj, field_offset);
}
}
-void V8HeapExplorer::SetPropertyShortcutReference(
- HeapObject* parent_obj,
- HeapEntry* parent_entry,
- String* reference_name,
- Object* child_obj) {
+void V8HeapExplorer::SetPropertyShortcutReference(HeapObject* parent_obj,
+ HeapEntry* parent_entry,
+ String* reference_name,
+ Object* child_obj) {
HeapEntry* child_entry = GetEntry(child_obj);
if (child_entry != NULL) {
filler_->SetNamedReference(HeapGraphEdge::kShortcut,
=======================================
--- /branches/experimental/isolates/src/profile-generator.h Fri Mar 11
19:15:52 2011
+++ /branches/experimental/isolates/src/profile-generator.h Fri Mar 18
07:48:51 2011
@@ -1030,11 +1030,13 @@
void SetInternalReference(HeapObject* parent_obj,
HeapEntry* parent,
const char* reference_name,
- Object* child);
+ Object* child,
+ int field_offset = -1);
void SetInternalReference(HeapObject* parent_obj,
HeapEntry* parent,
int index,
- Object* child);
+ Object* child,
+ int field_offset = -1);
void SetHiddenReference(HeapObject* parent_obj,
HeapEntry* parent,
int index,
@@ -1042,7 +1044,8 @@
void SetPropertyReference(HeapObject* parent_obj,
HeapEntry* parent,
String* reference_name,
- Object* child);
+ Object* child,
+ int field_offset = -1);
void SetPropertyShortcutReference(HeapObject* parent_obj,
HeapEntry* parent,
String* reference_name,
@@ -1056,9 +1059,6 @@
HeapSnapshot* snapshot_;
HeapSnapshotsCollection* collection_;
SnapshottingProgressReportingInterface* progress_;
- // Used during references extraction to mark heap objects that
- // are references via non-hidden properties.
- HeapObjectsSet known_references_;
SnapshotFillerInterface* filler_;
static HeapObject* const kGcRootsObject;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev