Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Unified Diff: src/heap.cc

Issue 151019: Changed the global object representation (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/ia32/ic-ia32.cc » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
===================================================================
--- src/heap.cc (revision 2285)
+++ src/heap.cc (working copy)
@@ -1070,6 +1070,11 @@
if (obj->IsFailure()) return false;
oddball_map_ = Map::cast(obj);
+ obj = AllocatePartialMap(JS_GLOBAL_PROPERTY_CELL_TYPE,
+ JSGlobalPropertyCell::kSize);
+ if (obj->IsFailure()) return false;
+ global_property_cell_map_ = Map::cast(obj);
+
// Allocate the empty array
obj = AllocateEmptyFixedArray();
if (obj->IsFailure()) return false;
@@ -1095,6 +1100,10 @@
oddball_map()->set_instance_descriptors(empty_descriptor_array());
oddball_map()->set_code_cache(empty_fixed_array());
+ global_property_cell_map()->set_instance_descriptors(
+ empty_descriptor_array());
+ global_property_cell_map()->set_code_cache(empty_fixed_array());
+
// Fix prototype object for existing maps.
meta_map()->set_prototype(null_value());
meta_map()->set_constructor(null_value());
@@ -1104,6 +1113,9 @@
oddball_map()->set_prototype(null_value());
oddball_map()->set_constructor(null_value());
+ global_property_cell_map()->set_prototype(null_value());
+ global_property_cell_map()->set_constructor(null_value());
+
obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize);
if (obj->IsFailure()) return false;
heap_number_map_ = Map::cast(obj);
@@ -1230,6 +1242,17 @@
}
+Object* Heap::AllocateJSGlobalPropertyCell(Object* value) {
+ Object* result = AllocateRaw(JSGlobalPropertyCell::kSize,
+ OLD_POINTER_SPACE,
+ OLD_POINTER_SPACE);
+ if (result->IsFailure()) return result;
+ HeapObject::cast(result)->set_map(global_property_cell_map());
+ JSGlobalPropertyCell::cast(result)->set_value(value);
+ return result;
+}
+
+
Object* Heap::CreateOddball(Map* map,
const char* to_string,
Object* to_number) {
@@ -2034,10 +2057,37 @@
Map::cast(initial_map)->set_constructor(constructor);
}
// Allocate the object based on the constructors initial map.
- return AllocateJSObjectFromMap(constructor->initial_map(), pretenure);
+ Object* result =
+ AllocateJSObjectFromMap(constructor->initial_map(), pretenure);
+ // Make sure result is NOT a JS global object if valid.
+ ASSERT(result->IsFailure() || !result->IsJSGlobalObject());
+ return result;
}
+Object* Heap::AllocateJSGlobalObject(JSFunction* constructor) {
+ ASSERT(constructor->has_initial_map());
+ // Make sure no field properties are described in the initial map.
+ // This guarantees us that normalizing the properties does not
+ // require us to change property values to JSGlobalPropertyCells.
+ ASSERT(constructor->initial_map()->NextFreePropertyIndex() == 0);
+
+ // Allocate the object based on the constructors initial map.
+ Object* result = AllocateJSObjectFromMap(constructor->initial_map(), TENURED);
+ if (result->IsFailure()) return result;
+
+ // Normalize the result.
+ JSObject* global = JSObject::cast(result);
+ result = global->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
+ if (result->IsFailure()) return result;
+
+ // Make sure result is a JS global object with properties in dictionary.
+ ASSERT(global->IsJSGlobalObject());
+ ASSERT(!global->HasFastProperties());
+ return global;
+}
+
+
Object* Heap::CopyJSObject(JSObject* source) {
// Never used to copy functions. If functions need to be copied we
// have to be careful to clear the literals array.
« no previous file with comments | « src/heap.h ('k') | src/ia32/ic-ia32.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698