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