Commit 85bc6029 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Reduce usage of StoreMode.

BUG=
R=ishell@chromium.org

Review URL: https://codereview.chromium.org/409603002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22511 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f9d631b4
...@@ -1869,15 +1869,9 @@ void JSObject::AddSlowProperty(Handle<JSObject> object, ...@@ -1869,15 +1869,9 @@ void JSObject::AddSlowProperty(Handle<JSObject> object,
MaybeHandle<Object> JSObject::AddPropertyInternal( MaybeHandle<Object> JSObject::AddPropertyInternal(
Handle<JSObject> object, Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
Handle<Name> name, PropertyAttributes attributes, JSReceiver::StoreFromKeyed store_mode,
Handle<Object> value, ExtensibilityCheck extensibility_check, TransitionFlag transition_flag) {
PropertyAttributes attributes,
StrictMode strict_mode,
JSReceiver::StoreFromKeyed store_mode,
ExtensibilityCheck extensibility_check,
StoreMode mode,
TransitionFlag transition_flag) {
ASSERT(!object->IsJSGlobalProxy()); ASSERT(!object->IsJSGlobalProxy());
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
...@@ -1888,14 +1882,10 @@ MaybeHandle<Object> JSObject::AddPropertyInternal( ...@@ -1888,14 +1882,10 @@ MaybeHandle<Object> JSObject::AddPropertyInternal(
if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK && if (extensibility_check == PERFORM_EXTENSIBILITY_CHECK &&
!object->map()->is_extensible()) { !object->map()->is_extensible()) {
if (strict_mode == SLOPPY) { Handle<Object> args[1] = {name};
return value; Handle<Object> error = isolate->factory()->NewTypeError(
} else { "object_not_extensible", HandleVector(args, ARRAY_SIZE(args)));
Handle<Object> args[1] = { name }; return isolate->Throw<Object>(error);
Handle<Object> error = isolate->factory()->NewTypeError(
"object_not_extensible", HandleVector(args, ARRAY_SIZE(args)));
return isolate->Throw<Object>(error);
}
} }
if (object->HasFastProperties()) { if (object->HasFastProperties()) {
...@@ -2259,11 +2249,10 @@ void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) { ...@@ -2259,11 +2249,10 @@ void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object, void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object,
int modify_index, int modify_index,
Representation new_representation, Representation new_representation,
Handle<HeapType> new_field_type, Handle<HeapType> new_field_type) {
StoreMode store_mode) {
Handle<Map> new_map = Map::GeneralizeRepresentation( Handle<Map> new_map = Map::GeneralizeRepresentation(
handle(object->map()), modify_index, new_representation, handle(object->map()), modify_index, new_representation, new_field_type,
new_field_type, store_mode); FORCE_FIELD);
MigrateToMap(object, new_map); MigrateToMap(object, new_map);
} }
...@@ -3992,9 +3981,9 @@ MaybeHandle<Object> JSObject::SetPropertyUsingTransition( ...@@ -3992,9 +3981,9 @@ MaybeHandle<Object> JSObject::SetPropertyUsingTransition(
// fast copy of the map. If we get a fast copy of the map, all field // fast copy of the map. If we get a fast copy of the map, all field
// representations will be tagged since the transition is omitted. // representations will be tagged since the transition is omitted.
return JSObject::AddPropertyInternal( return JSObject::AddPropertyInternal(
object, name, value, attributes, SLOPPY, object, name, value, attributes,
JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED, JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED,
JSReceiver::OMIT_EXTENSIBILITY_CHECK, FORCE_FIELD, OMIT_TRANSITION); JSReceiver::OMIT_EXTENSIBILITY_CHECK, OMIT_TRANSITION);
} }
// Keep the target CONSTANT if the same value is stored. // Keep the target CONSTANT if the same value is stored.
...@@ -4051,8 +4040,7 @@ void JSObject::SetPropertyToField(LookupResult* lookup, Handle<Object> value) { ...@@ -4051,8 +4040,7 @@ void JSObject::SetPropertyToField(LookupResult* lookup, Handle<Object> value) {
lookup->isolate(), field_representation); lookup->isolate(), field_representation);
JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()), JSObject::GeneralizeFieldRepresentation(handle(lookup->holder()),
lookup->GetDescriptorIndex(), lookup->GetDescriptorIndex(),
field_representation, field_type, field_representation, field_type);
FORCE_FIELD);
} }
lookup->holder()->WriteToField(lookup->GetDescriptorIndex(), *value); lookup->holder()->WriteToField(lookup->GetDescriptorIndex(), *value);
} }
...@@ -4074,9 +4062,9 @@ void JSObject::ConvertAndSetOwnProperty(LookupResult* lookup, ...@@ -4074,9 +4062,9 @@ void JSObject::ConvertAndSetOwnProperty(LookupResult* lookup,
int descriptor_index = lookup->GetDescriptorIndex(); int descriptor_index = lookup->GetDescriptorIndex();
if (lookup->GetAttributes() == attributes) { if (lookup->GetAttributes() == attributes) {
JSObject::GeneralizeFieldRepresentation( JSObject::GeneralizeFieldRepresentation(object, descriptor_index,
object, descriptor_index, Representation::Tagged(), Representation::Tagged(),
HeapType::Any(lookup->isolate()), FORCE_FIELD); HeapType::Any(lookup->isolate()));
} else { } else {
Handle<Map> old_map(object->map()); Handle<Map> old_map(object->map());
Handle<Map> new_map = Map::CopyGeneralizeAllRepresentations(old_map, Handle<Map> new_map = Map::CopyGeneralizeAllRepresentations(old_map,
...@@ -4101,12 +4089,9 @@ void JSObject::SetPropertyToFieldWithAttributes(LookupResult* lookup, ...@@ -4101,12 +4089,9 @@ void JSObject::SetPropertyToFieldWithAttributes(LookupResult* lookup,
} }
void JSObject::AddProperty( void JSObject::AddProperty(Handle<JSObject> object, Handle<Name> name,
Handle<JSObject> object, Handle<Object> value,
Handle<Name> name, PropertyAttributes attributes) {
Handle<Object> value,
PropertyAttributes attributes,
StoreMode store_mode) {
#ifdef DEBUG #ifdef DEBUG
uint32_t index; uint32_t index;
ASSERT(!object->IsJSProxy()); ASSERT(!object->IsJSProxy());
...@@ -4116,7 +4101,7 @@ void JSObject::AddProperty( ...@@ -4116,7 +4101,7 @@ void JSObject::AddProperty(
ASSERT(!it.IsFound()); ASSERT(!it.IsFound());
ASSERT(object->map()->is_extensible()); ASSERT(object->map()->is_extensible());
#endif #endif
SetOwnPropertyIgnoreAttributes(object, name, value, attributes, store_mode, SetOwnPropertyIgnoreAttributes(object, name, value, attributes,
OMIT_EXTENSIBILITY_CHECK).Check(); OMIT_EXTENSIBILITY_CHECK).Check();
} }
...@@ -4128,7 +4113,6 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( ...@@ -4128,7 +4113,6 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
Handle<Name> name, Handle<Name> name,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes, PropertyAttributes attributes,
StoreMode mode,
ExtensibilityCheck extensibility_check, ExtensibilityCheck extensibility_check,
StoreFromKeyed store_from_keyed, StoreFromKeyed store_from_keyed,
ExecutableAccessorInfoHandling handling) { ExecutableAccessorInfoHandling handling) {
...@@ -4159,7 +4143,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( ...@@ -4159,7 +4143,7 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
ASSERT(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject()); ASSERT(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return SetOwnPropertyIgnoreAttributes( return SetOwnPropertyIgnoreAttributes(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), name, Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), name,
value, attributes, mode, extensibility_check); value, attributes, extensibility_check);
} }
if (lookup.IsInterceptor() || if (lookup.IsInterceptor() ||
...@@ -4173,9 +4157,8 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes( ...@@ -4173,9 +4157,8 @@ MaybeHandle<Object> JSObject::SetOwnPropertyIgnoreAttributes(
TransitionFlag flag = lookup.IsFound() TransitionFlag flag = lookup.IsFound()
? OMIT_TRANSITION : INSERT_TRANSITION; ? OMIT_TRANSITION : INSERT_TRANSITION;
// Neither properties nor transitions found. // Neither properties nor transitions found.
return AddPropertyInternal(object, name, value, attributes, SLOPPY, return AddPropertyInternal(object, name, value, attributes,
store_from_keyed, extensibility_check, mode, store_from_keyed, extensibility_check, flag);
flag);
} }
Handle<Object> old_value = isolate->factory()->the_hole_value(); Handle<Object> old_value = isolate->factory()->the_hole_value();
...@@ -5141,7 +5124,7 @@ Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject> object, ...@@ -5141,7 +5124,7 @@ Handle<Object> JSObject::SetHiddenPropertiesHashTable(Handle<JSObject> object,
} }
SetOwnPropertyIgnoreAttributes(object, isolate->factory()->hidden_string(), SetOwnPropertyIgnoreAttributes(object, isolate->factory()->hidden_string(),
value, DONT_ENUM, ALLOW_AS_CONSTANT, value, DONT_ENUM,
OMIT_EXTENSIBILITY_CHECK).Assert(); OMIT_EXTENSIBILITY_CHECK).Assert();
return object; return object;
} }
......
...@@ -2157,16 +2157,12 @@ class JSObject: public JSReceiver { ...@@ -2157,16 +2157,12 @@ class JSObject: public JSReceiver {
Handle<Name> key, Handle<Name> key,
Handle<Object> value, Handle<Object> value,
PropertyAttributes attributes, PropertyAttributes attributes,
StoreMode mode = ALLOW_AS_CONSTANT,
ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING);
static void AddProperty(Handle<JSObject> object, static void AddProperty(Handle<JSObject> object, Handle<Name> key,
Handle<Name> key, Handle<Object> value, PropertyAttributes attributes);
Handle<Object> value,
PropertyAttributes attributes,
StoreMode mode = ALLOW_AS_CONSTANT);
// Extend the receiver with a single fast property appeared first in the // Extend the receiver with a single fast property appeared first in the
// passed map. This also extends the property backing store if necessary. // passed map. This also extends the property backing store if necessary.
...@@ -2650,8 +2646,7 @@ class JSObject: public JSReceiver { ...@@ -2650,8 +2646,7 @@ class JSObject: public JSReceiver {
static void GeneralizeFieldRepresentation(Handle<JSObject> object, static void GeneralizeFieldRepresentation(Handle<JSObject> object,
int modify_index, int modify_index,
Representation new_representation, Representation new_representation,
Handle<HeapType> new_field_type, Handle<HeapType> new_field_type);
StoreMode store_mode);
static void UpdateAllocationSite(Handle<JSObject> object, static void UpdateAllocationSite(Handle<JSObject> object,
ElementsKind to_kind); ElementsKind to_kind);
...@@ -2733,15 +2728,9 @@ class JSObject: public JSReceiver { ...@@ -2733,15 +2728,9 @@ class JSObject: public JSReceiver {
// Add a property to an object. // Add a property to an object.
MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal( MUST_USE_RESULT static MaybeHandle<Object> AddPropertyInternal(
Handle<JSObject> object, Handle<JSObject> object, Handle<Name> name, Handle<Object> value,
Handle<Name> name, PropertyAttributes attributes, StoreFromKeyed store_mode,
Handle<Object> value, ExtensibilityCheck extensibility_check, TransitionFlag flag);
PropertyAttributes attributes,
StrictMode strict_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
StoreMode mode = ALLOW_AS_CONSTANT,
TransitionFlag flag = INSERT_TRANSITION);
// Add a property to a fast-case object. // Add a property to a fast-case object.
static void AddFastProperty(Handle<JSObject> object, static void AddFastProperty(Handle<JSObject> object,
......
...@@ -267,7 +267,6 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( ...@@ -267,7 +267,6 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
} }
MaybeHandle<Object> maybe_result; MaybeHandle<Object> maybe_result;
uint32_t element_index = 0; uint32_t element_index = 0;
StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT;
if (key->IsInternalizedString()) { if (key->IsInternalizedString()) {
if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
// Array index as string (uint32). // Array index as string (uint32).
...@@ -278,7 +277,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( ...@@ -278,7 +277,7 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
Handle<String> name(String::cast(*key)); Handle<String> name(String::cast(*key));
ASSERT(!name->AsArrayIndex(&element_index)); ASSERT(!name->AsArrayIndex(&element_index));
maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
boilerplate, name, value, NONE, mode); boilerplate, name, value, NONE);
} }
} else if (key->ToArrayIndex(&element_index)) { } else if (key->ToArrayIndex(&element_index)) {
// Array index (uint32). // Array index (uint32).
...@@ -293,8 +292,8 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( ...@@ -293,8 +292,8 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
Vector<char> buffer(arr, ARRAY_SIZE(arr)); Vector<char> buffer(arr, ARRAY_SIZE(arr));
const char* str = DoubleToCString(num, buffer); const char* str = DoubleToCString(num, buffer);
Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
boilerplate, name, value, NONE, mode); value, NONE);
} }
// If setting the property on the boilerplate throws an // If setting the property on the boilerplate throws an
// exception, the exception is converted to an empty handle in // exception, the exception is converted to an empty handle in
...@@ -4979,7 +4978,6 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) { ...@@ -4979,7 +4978,6 @@ RUNTIME_FUNCTION(Runtime_DefineDataPropertyUnchecked) {
isolate, result, isolate, result,
JSObject::SetOwnPropertyIgnoreAttributes( JSObject::SetOwnPropertyIgnoreAttributes(
js_object, name, obj_value, attr, js_object, name, obj_value, attr,
ALLOW_AS_CONSTANT,
JSReceiver::PERFORM_EXTENSIBILITY_CHECK, JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
JSReceiver::MAY_BE_STORE_FROM_KEYED, JSReceiver::MAY_BE_STORE_FROM_KEYED,
JSObject::DONT_FORCE_FIELD)); JSObject::DONT_FORCE_FIELD));
...@@ -5132,8 +5130,8 @@ MaybeHandle<Object> Runtime::DefineObjectProperty( ...@@ -5132,8 +5130,8 @@ MaybeHandle<Object> Runtime::DefineObjectProperty(
} else { } else {
if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
return JSObject::SetOwnPropertyIgnoreAttributes( return JSObject::SetOwnPropertyIgnoreAttributes(
js_object, name, value, attr, ALLOW_AS_CONSTANT, js_object, name, value, attr, JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
JSReceiver::PERFORM_EXTENSIBILITY_CHECK, store_from_keyed); store_from_keyed);
} }
} }
...@@ -5148,8 +5146,8 @@ MaybeHandle<Object> Runtime::DefineObjectProperty( ...@@ -5148,8 +5146,8 @@ MaybeHandle<Object> Runtime::DefineObjectProperty(
SLOPPY, false, DEFINE_PROPERTY); SLOPPY, false, DEFINE_PROPERTY);
} else { } else {
return JSObject::SetOwnPropertyIgnoreAttributes( return JSObject::SetOwnPropertyIgnoreAttributes(
js_object, name, value, attr, ALLOW_AS_CONSTANT, js_object, name, value, attr, JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
JSReceiver::PERFORM_EXTENSIBILITY_CHECK, store_from_keyed); store_from_keyed);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment