}
-Object* CallStubCompiler::CompileCallGlobal(JSGlobalObject* object,
+Object* CallStubCompiler::CompileCallGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name) {
}
-Object* StoreStubCompiler::CompileStoreGlobal(JSGlobalObject* object,
+Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name) {
// ----------- S t a t e -------------
}
-Object* LoadStubCompiler::CompileLoadGlobal(JSGlobalObject* object,
+Object* LoadStubCompiler::CompileLoadGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
{ // --- G l o b a l ---
// Step 1: create a fresh inner JSGlobalObject
- Handle<JSGlobalObject> object;
+ Handle<GlobalObject> object;
{
Handle<JSFunction> js_global_function;
Handle<ObjectTemplateInfo> js_global_template;
}
js_global_function->initial_map()->set_is_hidden_prototype();
- SetExpectedNofProperties(js_global_function, 100);
- object = Factory::NewJSGlobalObject(js_global_function);
+ object = Factory::NewGlobalObject(js_global_function);
}
// Set the global context for the global object.
Handle<String> name = Factory::LookupAsciiSymbol("builtins");
builtins_fun->shared()->set_instance_class_name(*name);
- SetExpectedNofProperties(builtins_fun, 100);
// Allocate the builtins object.
Handle<JSBuiltinsObject> builtins =
- Handle<JSBuiltinsObject>::cast(Factory::NewJSObject(builtins_fun,
- TENURED));
+ Handle<JSBuiltinsObject>::cast(Factory::NewGlobalObject(builtins_fun));
builtins->set_builtins(*builtins);
builtins->set_global_context(*global_context());
builtins->set_global_receiver(*builtins);
apply->shared()->set_length(2);
}
- // Make sure that the builtins object has fast properties.
- // If the ASSERT below fails, please increase the expected number of
- // properties for the builtins object.
- ASSERT(builtins->HasFastProperties());
#ifdef DEBUG
builtins->Verify();
#endif
}
-Handle<JSGlobalObject> Factory::NewJSGlobalObject(
+Handle<GlobalObject> Factory::NewGlobalObject(
Handle<JSFunction> constructor) {
- CALL_HEAP_FUNCTION(Heap::AllocateJSGlobalObject(*constructor),
- JSGlobalObject);
+ CALL_HEAP_FUNCTION(Heap::AllocateGlobalObject(*constructor),
+ GlobalObject);
}
static Handle<JSObject> NewJSObject(Handle<JSFunction> constructor,
PretenureFlag pretenure = NOT_TENURED);
- // JS global objects are pretenured.
- static Handle<JSGlobalObject> NewJSGlobalObject(
- Handle<JSFunction> constructor);
+ // Global objects are pretenured.
+ static Handle<GlobalObject> NewGlobalObject(Handle<JSFunction> constructor);
// JS objects are pretenured when allocated by the bootstrapper and
// runtime.
Object* Heap::AllocateSharedFunctionInfo(Object* name) {
- Object* result = Allocate(shared_function_info_map(), NEW_SPACE);
+ Object* result = Allocate(shared_function_info_map(), OLD_POINTER_SPACE);
if (result->IsFailure()) return result;
SharedFunctionInfo* share = SharedFunctionInfo::cast(result);
// Allocate the backing storage for the properties.
int prop_size = map->unused_property_fields() - map->inobject_properties();
- Object* properties = AllocateFixedArray(prop_size);
+ Object* properties = AllocateFixedArray(prop_size, pretenure);
if (properties->IsFailure()) return properties;
// Allocate the JSObject.
// Allocate the object based on the constructors initial map.
Object* result =
AllocateJSObjectFromMap(constructor->initial_map(), pretenure);
- // Make sure result is NOT a JS global object if valid.
- ASSERT(result->IsFailure() || !result->IsJSGlobalObject());
+ // Make sure result is NOT a global object if valid.
+ ASSERT(result->IsFailure() || !result->IsGlobalObject());
return result;
}
-Object* Heap::AllocateJSGlobalObject(JSFunction* constructor) {
+Object* Heap::AllocateGlobalObject(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);
+ // Make sure we don't have a ton of pre-allocated slots in the
+ // global objects. They will be unused once we normalize the object.
+ ASSERT(constructor->initial_map()->unused_property_fields() == 0);
+ ASSERT(constructor->initial_map()->inobject_properties() == 0);
+
// Allocate the object based on the constructors initial map.
Object* result = AllocateJSObjectFromMap(constructor->initial_map(), TENURED);
if (result->IsFailure()) return 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());
+ // Make sure result is a global object with properties in dictionary.
+ ASSERT(global->IsGlobalObject());
ASSERT(!global->HasFastProperties());
return global;
}
// Allocate the backing storage for the properties.
int prop_size = map->unused_property_fields() - map->inobject_properties();
- Object* properties = AllocateFixedArray(prop_size);
+ Object* properties = AllocateFixedArray(prop_size, TENURED);
if (properties->IsFailure()) return properties;
// Reset the map for the object.
static Object* AllocateJSObject(JSFunction* constructor,
PretenureFlag pretenure = NOT_TENURED);
- // Allocates and initializes a new JS global object based on a constructor.
+ // Allocates and initializes a new global object based on a constructor.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
// failed.
// Please note this does not perform a garbage collection.
- static Object* AllocateJSGlobalObject(JSFunction* constructor);
+ static Object* AllocateGlobalObject(JSFunction* constructor);
// Returns a deep copy of the JavaScript object.
// Properties and elements are copied too.
}
-Object* CallStubCompiler::CompileCallGlobal(JSGlobalObject* object,
+Object* CallStubCompiler::CompileCallGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name) {
}
-Object* StoreStubCompiler::CompileStoreGlobal(JSGlobalObject* object,
+Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name) {
// ----------- S t a t e -------------
}
-Object* LoadStubCompiler::CompileLoadGlobal(JSGlobalObject* object,
+Object* LoadStubCompiler::CompileLoadGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
}
case NORMAL: {
if (!object->IsJSObject()) return;
- if (object->IsJSGlobalObject()) {
+ if (object->IsGlobalObject()) {
// The stub generated for the global object picks the value directly
// from the property cell. So the property must be directly on the
// global object.
- Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(object);
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
if (lookup->holder() != *global) return;
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
break;
}
case NORMAL: {
- if (object->IsJSGlobalObject()) {
+ if (object->IsGlobalObject()) {
// The stub generated for the global object picks the value directly
// from the property cell. So the property must be directly on the
// global object.
- Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(object);
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(object);
if (lookup->holder() != *global) return;
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
break;
}
case NORMAL: {
- if (!receiver->IsJSGlobalObject()) {
+ if (!receiver->IsGlobalObject()) {
return;
}
// The stub generated for the global object picks the value directly
// from the property cell. So the property must be directly on the
// global object.
- Handle<JSGlobalObject> global = Handle<JSGlobalObject>::cast(receiver);
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
code = StubCache::ComputeStoreGlobal(*name, *global, cell);
Object* JSObject::GetNormalizedProperty(LookupResult* result) {
ASSERT(!HasFastProperties());
Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
value = JSGlobalPropertyCell::cast(value)->value();
}
ASSERT(!value->IsJSGlobalPropertyCell());
Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) {
ASSERT(!HasFastProperties());
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(
property_dictionary()->ValueAt(result->GetDictionaryEntry()));
int entry = property_dictionary()->FindStringEntry(name);
if (entry == Dictionary::kNotFound) {
Object* store_value = value;
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
store_value = Heap::AllocateJSGlobalPropertyCell(value);
if (store_value->IsFailure()) return store_value;
}
details = PropertyDetails(details.attributes(),
details.type(),
property_dictionary()->DetailsAt(entry).index());
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
JSGlobalPropertyCell* cell =
JSGlobalPropertyCell::cast(property_dictionary()->ValueAt(entry));
cell->set_value(value);
int entry = dictionary->FindStringEntry(name);
if (entry != Dictionary::kNotFound) {
// If we have a global object set the cell to the hole.
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
PropertyDetails details = dictionary->DetailsAt(entry);
if (details.IsDontDelete() && mode != FORCE_DELETION) {
return Heap::false_value();
ASSERT(!HasFastProperties());
Dictionary* dict = property_dictionary();
Object* store_value = value;
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
// In case name is an orphaned property reuse the cell.
int entry = dict->FindStringEntry(name);
if (entry != Dictionary::kNotFound) {
// Make sure to disallow caching for uninitialized constants
// found in the dictionary-mode objects.
Object* value = property_dictionary()->ValueAt(entry);
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
PropertyDetails d = property_dictionary()->DetailsAt(entry);
if (d.IsDeleted()) {
result->NotFound();
PropertyDetails d =
PropertyDetails(details.attributes(), NORMAL, details.index());
Object* value = r.GetConstantFunction();
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
value = Heap::AllocateJSGlobalPropertyCell(value);
if (value->IsFailure()) return value;
}
PropertyDetails d =
PropertyDetails(details.attributes(), NORMAL, details.index());
Object* value = FastPropertyAt(r.GetFieldIndex());
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
value = Heap::AllocateJSGlobalPropertyCell(value);
if (value->IsFailure()) return value;
}
PropertyDetails d =
PropertyDetails(details.attributes(), CALLBACKS, details.index());
Object* value = r.GetCallbacksObject();
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
value = Heap::AllocateJSGlobalPropertyCell(value);
if (value->IsFailure()) return value;
}
Object* JSObject::TransformToFastProperties(int unused_property_fields) {
if (HasFastProperties()) return this;
- ASSERT(!IsJSGlobalObject());
+ ASSERT(!IsGlobalObject());
return property_dictionary()->
- TransformPropertiesToFastFor(this, unused_property_fields);
+ TransformPropertiesToFastFor(this, unused_property_fields);
}
// For the global object allocate a new map to invalidate the global inline
// caches which have a global property cell reference directly in the code.
- if (IsJSGlobalObject()) {
+ if (IsGlobalObject()) {
Object* new_map = map()->CopyDropDescriptors();
if (new_map->IsFailure()) return new_map;
set_map(Map::cast(new_map));
}
-Object* JSGlobalObject::GetPropertyCell(LookupResult* result) {
+Object* GlobalObject::GetPropertyCell(LookupResult* result) {
ASSERT(!HasFastProperties());
Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry());
ASSERT(value->IsJSGlobalPropertyCell());
// [global receiver]: the global receiver object of the context
DECL_ACCESSORS(global_receiver, JSObject)
+ // Retrieve the property cell used to store a property.
+ Object* GetPropertyCell(LookupResult* result);
+
// Casting.
static inline GlobalObject* cast(Object* obj);
class JSGlobalObject: public GlobalObject {
public:
- // Retrieve the property cell used to store a property.
- Object* GetPropertyCell(LookupResult* result);
-
// Casting.
static inline JSGlobalObject* cast(Object* obj);
case NORMAL: {
Object* value;
value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry());
- if (holder()->IsJSGlobalObject()) {
+ if (holder()->IsGlobalObject()) {
value = JSGlobalPropertyCell::cast(value)->value();
}
return value;
if ((entry != Dictionary::kNotFound) &&
(dictionary->DetailsAt(entry).type() == NORMAL)) {
Object* value = dictionary->ValueAt(entry);
- if (receiver->IsJSGlobalObject()) {
+ if (receiver->IsGlobalObject()) {
value = JSGlobalPropertyCell::cast(value)->value();
}
return value;
Object* StubCache::ComputeLoadGlobal(String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell,
bool is_dont_delete) {
Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, NORMAL);
Object* StubCache::ComputeStoreGlobal(String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell) {
Code::Flags flags = Code::ComputeMonomorphicFlags(Code::STORE_IC, NORMAL);
Object* code = receiver->map()->FindInCodeCache(name, flags);
Object* StubCache::ComputeCallGlobal(int argc,
InLoopFlag in_loop,
String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell,
JSFunction* function) {
Code::Flags flags =
static Object* ComputeLoadGlobal(String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell,
bool is_dont_delete);
Map* transition = NULL);
static Object* ComputeStoreGlobal(String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell);
static Object* ComputeStoreCallback(String* name,
static Object* ComputeCallGlobal(int argc,
InLoopFlag in_loop,
String* name,
- JSGlobalObject* receiver,
+ GlobalObject* receiver,
JSGlobalPropertyCell* cell,
JSFunction* function);
JSObject* holder,
String* name);
- Object* CompileLoadGlobal(JSGlobalObject* object,
+ Object* CompileLoadGlobal(GlobalObject* object,
JSGlobalPropertyCell* holder,
String* name,
bool is_dont_delete);
AccessorInfo* callbacks,
String* name);
Object* CompileStoreInterceptor(JSObject* object, String* name);
- Object* CompileStoreGlobal(JSGlobalObject* object,
+ Object* CompileStoreGlobal(GlobalObject* object,
JSGlobalPropertyCell* holder,
String* name);
Object* CompileCallInterceptor(Object* object,
JSObject* holder,
String* name);
- Object* CompileCallGlobal(JSGlobalObject* object,
+ Object* CompileCallGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name);
-Object* CallStubCompiler::CompileCallGlobal(JSGlobalObject* object,
+Object* CallStubCompiler::CompileCallGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
JSFunction* function,
String* name) {
}
-Object* LoadStubCompiler::CompileLoadGlobal(JSGlobalObject* object,
+Object* LoadStubCompiler::CompileLoadGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name,
bool is_dont_delete) {
}
-Object* StoreStubCompiler::CompileStoreGlobal(JSGlobalObject* object,
+Object* StoreStubCompiler::CompileStoreGlobal(GlobalObject* object,
JSGlobalPropertyCell* cell,
String* name) {
UNIMPLEMENTED();