Move handlified functions from handles.cc to objects.cc
BUG= TEST= Review URL: http://codereview.chromium.org/9008012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10348 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
c427c35c87
commit
746ef93362
13
src/api.cc
13
src/api.cc
@ -2739,7 +2739,7 @@ bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
|
||||
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
|
||||
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
|
||||
EXCEPTION_PREAMBLE(isolate);
|
||||
i::Handle<i::Object> obj = i::SetElement(
|
||||
i::Handle<i::Object> obj = i::JSObject::SetElement(
|
||||
self,
|
||||
index,
|
||||
value_obj,
|
||||
@ -2845,7 +2845,7 @@ Local<Value> v8::Object::GetPrototype() {
|
||||
return Local<v8::Value>());
|
||||
ENTER_V8(isolate);
|
||||
i::Handle<i::Object> self = Utils::OpenHandle(this);
|
||||
i::Handle<i::Object> result = i::GetPrototype(self);
|
||||
i::Handle<i::Object> result(self->GetPrototype());
|
||||
return Utils::ToLocal(result);
|
||||
}
|
||||
|
||||
@ -2999,7 +2999,7 @@ bool v8::Object::Delete(v8::Handle<String> key) {
|
||||
i::HandleScope scope(isolate);
|
||||
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
|
||||
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
|
||||
return i::DeleteProperty(self, key_obj)->IsTrue();
|
||||
return i::JSObject::DeleteProperty(self, key_obj)->IsTrue();
|
||||
}
|
||||
|
||||
|
||||
@ -3020,7 +3020,7 @@ bool v8::Object::Delete(uint32_t index) {
|
||||
ENTER_V8(isolate);
|
||||
HandleScope scope;
|
||||
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
|
||||
return i::DeleteElement(self, index)->IsTrue();
|
||||
return i::JSObject::DeleteElement(self, index)->IsTrue();
|
||||
}
|
||||
|
||||
|
||||
@ -3225,7 +3225,7 @@ int v8::Object::GetIdentityHash() {
|
||||
ENTER_V8(isolate);
|
||||
i::HandleScope scope(isolate);
|
||||
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
|
||||
return i::GetIdentityHash(self);
|
||||
return i::JSObject::GetIdentityHash(self);
|
||||
}
|
||||
|
||||
|
||||
@ -3238,7 +3238,8 @@ bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key,
|
||||
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
|
||||
i::Handle<i::String> key_obj = Utils::OpenHandle(*key);
|
||||
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
|
||||
i::Handle<i::Object> result = i::SetHiddenProperty(self, key_obj, value_obj);
|
||||
i::Handle<i::Object> result =
|
||||
i::JSObject::SetHiddenProperty(self, key_obj, value_obj);
|
||||
return *result == *self;
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,9 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
|
||||
} else {
|
||||
attributes = DONT_ENUM;
|
||||
}
|
||||
SetLocalPropertyNoThrow(target, symbol, function, attributes);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
target, symbol, function, attributes));
|
||||
if (is_ecma_native) {
|
||||
function->shared()->set_instance_class_name(*symbol);
|
||||
}
|
||||
@ -600,7 +602,7 @@ Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
|
||||
throw_type_error_function->shared()->set_code(*code);
|
||||
throw_type_error_function->shared()->DontAdaptArguments();
|
||||
|
||||
PreventExtensions(throw_type_error_function);
|
||||
JSObject::PreventExtensions(throw_type_error_function);
|
||||
}
|
||||
return throw_type_error_function;
|
||||
}
|
||||
@ -753,11 +755,10 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
||||
Handle<JSObject> prototype =
|
||||
Handle<JSObject>(
|
||||
JSObject::cast(js_global_function->instance_prototype()));
|
||||
SetLocalPropertyNoThrow(
|
||||
prototype,
|
||||
factory()->constructor_symbol(),
|
||||
isolate()->object_function(),
|
||||
NONE);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
prototype, factory()->constructor_symbol(),
|
||||
isolate()->object_function(), NONE));
|
||||
} else {
|
||||
Handle<FunctionTemplateInfo> js_global_constructor(
|
||||
FunctionTemplateInfo::cast(js_global_template->constructor()));
|
||||
@ -863,8 +864,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Heap* heap = isolate->heap();
|
||||
|
||||
Handle<String> object_name = Handle<String>(heap->Object_symbol());
|
||||
SetLocalPropertyNoThrow(inner_global, object_name,
|
||||
isolate->object_function(), DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
inner_global, object_name,
|
||||
isolate->object_function(), DONT_ENUM));
|
||||
|
||||
Handle<JSObject> global = Handle<JSObject>(global_context()->global());
|
||||
|
||||
@ -1046,14 +1049,15 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
|
||||
{ // -- J S O N
|
||||
Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
|
||||
Handle<JSFunction> cons = factory->NewFunction(
|
||||
name,
|
||||
factory->the_hole_value());
|
||||
Handle<JSFunction> cons = factory->NewFunction(name,
|
||||
factory->the_hole_value());
|
||||
cons->SetInstancePrototype(global_context()->initial_object_prototype());
|
||||
cons->SetInstanceClassName(*name);
|
||||
Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
|
||||
ASSERT(json_object->IsJSObject());
|
||||
SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
global, name, json_object, DONT_ENUM));
|
||||
global_context()->set_json_object(*json_object);
|
||||
}
|
||||
|
||||
@ -1083,12 +1087,14 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
global_context()->set_arguments_boilerplate(*result);
|
||||
// Note: length must be added as the first property and
|
||||
// callee must be added as the second property.
|
||||
SetLocalPropertyNoThrow(result, factory->length_symbol(),
|
||||
factory->undefined_value(),
|
||||
DONT_ENUM);
|
||||
SetLocalPropertyNoThrow(result, factory->callee_symbol(),
|
||||
factory->undefined_value(),
|
||||
DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
result, factory->length_symbol(),
|
||||
factory->undefined_value(), DONT_ENUM));
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
result, factory->callee_symbol(),
|
||||
factory->undefined_value(), DONT_ENUM));
|
||||
|
||||
#ifdef DEBUG
|
||||
LookupResult lookup(isolate);
|
||||
@ -1183,9 +1189,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
global_context()->set_strict_mode_arguments_boilerplate(*result);
|
||||
|
||||
// Add length property only for strict mode boilerplate.
|
||||
SetLocalPropertyNoThrow(result, factory->length_symbol(),
|
||||
factory->undefined_value(),
|
||||
DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
result, factory->length_symbol(),
|
||||
factory->undefined_value(), DONT_ENUM));
|
||||
|
||||
#ifdef DEBUG
|
||||
LookupResult lookup(isolate);
|
||||
@ -1448,7 +1455,9 @@ bool Genesis::InstallNatives() {
|
||||
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
|
||||
Handle<String> global_symbol = factory()->LookupAsciiSymbol("global");
|
||||
Handle<Object> global_obj(global_context()->global());
|
||||
SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
builtins, global_symbol, global_obj, attributes));
|
||||
|
||||
// Setup the reference from the global object to the builtins object.
|
||||
JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins);
|
||||
@ -1911,25 +1920,28 @@ bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
|
||||
|
||||
|
||||
void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
|
||||
Factory* factory = global_context->GetIsolate()->factory();
|
||||
Isolate* isolate = global_context->GetIsolate();
|
||||
Factory* factory = isolate->factory();
|
||||
HandleScope scope;
|
||||
Handle<JSGlobalObject> js_global(
|
||||
JSGlobalObject::cast(global_context->global()));
|
||||
Handle<JSGlobalObject> global(JSGlobalObject::cast(global_context->global()));
|
||||
// Expose the natives in global if a name for it is specified.
|
||||
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
|
||||
Handle<String> natives_string =
|
||||
factory->LookupAsciiSymbol(FLAG_expose_natives_as);
|
||||
SetLocalPropertyNoThrow(js_global, natives_string,
|
||||
Handle<JSObject>(js_global->builtins()), DONT_ENUM);
|
||||
Handle<String> natives = factory->LookupAsciiSymbol(FLAG_expose_natives_as);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
global, natives,
|
||||
Handle<JSObject>(global->builtins()),
|
||||
DONT_ENUM));
|
||||
}
|
||||
|
||||
Handle<Object> Error = GetProperty(js_global, "Error");
|
||||
Handle<Object> Error = GetProperty(global, "Error");
|
||||
if (Error->IsJSObject()) {
|
||||
Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit");
|
||||
SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error),
|
||||
name,
|
||||
Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
|
||||
NONE);
|
||||
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit));
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
Handle<JSObject>::cast(Error), name,
|
||||
stack_trace_limit, NONE));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUGGER_SUPPORT
|
||||
@ -1948,7 +1960,9 @@ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
|
||||
Handle<String> debug_string =
|
||||
factory->LookupAsciiSymbol(FLAG_expose_debug_as);
|
||||
Handle<Object> global_proxy(debug->debug_context()->global_proxy());
|
||||
SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
global, debug_string, global_proxy, DONT_ENUM));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2164,7 +2178,9 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<String> key = Handle<String>(descs->GetKey(i));
|
||||
int index = descs->GetFieldIndex(i);
|
||||
Handle<Object> value = Handle<Object>(from->FastPropertyAt(index));
|
||||
SetLocalPropertyNoThrow(to, key, value, details.attributes());
|
||||
CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
to, key, value, details.attributes()));
|
||||
break;
|
||||
}
|
||||
case CONSTANT_FUNCTION: {
|
||||
@ -2172,7 +2188,9 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<String> key = Handle<String>(descs->GetKey(i));
|
||||
Handle<JSFunction> fun =
|
||||
Handle<JSFunction>(descs->GetConstantFunction(i));
|
||||
SetLocalPropertyNoThrow(to, key, fun, details.attributes());
|
||||
CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
to, key, fun, details.attributes()));
|
||||
break;
|
||||
}
|
||||
case CALLBACKS: {
|
||||
@ -2187,7 +2205,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<Object> callbacks(descs->GetCallbacksObject(i));
|
||||
PropertyDetails d =
|
||||
PropertyDetails(details.attributes(), CALLBACKS, details.index());
|
||||
SetNormalizedProperty(to, key, callbacks, d);
|
||||
JSObject::SetNormalizedProperty(to, key, callbacks, d);
|
||||
break;
|
||||
}
|
||||
case MAP_TRANSITION:
|
||||
@ -2224,7 +2242,9 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value());
|
||||
}
|
||||
PropertyDetails details = properties->DetailsAt(i);
|
||||
SetLocalPropertyNoThrow(to, key, value, details.attributes());
|
||||
CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
to, key, value, details.attributes()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -827,8 +827,8 @@ bool Debug::Load() {
|
||||
Handle<GlobalObject> global = Handle<GlobalObject>(context->global());
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(
|
||||
isolate_,
|
||||
SetProperty(global, key, Handle<Object>(global->builtins()),
|
||||
NONE, kNonStrictMode),
|
||||
JSReceiver::SetProperty(global, key, Handle<Object>(global->builtins()),
|
||||
NONE, kNonStrictMode),
|
||||
false);
|
||||
|
||||
// Compile the JavaScript for the debugger in the debugger context.
|
||||
|
@ -751,7 +751,10 @@ Handle<JSFunction> Factory::NewFunctionWithPrototype(Handle<String> name,
|
||||
// property that refers to the function.
|
||||
SetPrototypeProperty(function, prototype);
|
||||
// Currently safe because it is only invoked from Genesis.
|
||||
SetLocalPropertyNoThrow(prototype, constructor_symbol(), function, DONT_ENUM);
|
||||
CHECK_NOT_EMPTY_HANDLE(isolate(),
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
prototype, constructor_symbol(),
|
||||
function, DONT_ENUM));
|
||||
return function;
|
||||
}
|
||||
|
||||
|
162
src/handles.cc
162
src/handles.cc
@ -208,42 +208,6 @@ void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
|
||||
}
|
||||
|
||||
|
||||
void NormalizeProperties(Handle<JSObject> object,
|
||||
PropertyNormalizationMode mode,
|
||||
int expected_additional_properties) {
|
||||
CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
|
||||
object->NormalizeProperties(
|
||||
mode,
|
||||
expected_additional_properties));
|
||||
}
|
||||
|
||||
|
||||
Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->NormalizeElements(),
|
||||
NumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
void TransformToFastProperties(Handle<JSObject> object,
|
||||
int unused_property_fields) {
|
||||
CALL_HEAP_FUNCTION_VOID(
|
||||
object->GetIsolate(),
|
||||
object->TransformToFastProperties(unused_property_fields));
|
||||
}
|
||||
|
||||
|
||||
Handle<NumberDictionary> NumberDictionarySet(
|
||||
Handle<NumberDictionary> dictionary,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
|
||||
dictionary->Set(index, *value, details),
|
||||
NumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
void FlattenString(Handle<String> string) {
|
||||
CALL_HEAP_FUNCTION_VOID(string->GetIsolate(), string->TryFlatten());
|
||||
}
|
||||
@ -265,17 +229,6 @@ Handle<Object> SetPrototype(Handle<JSFunction> function,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetProperty(Handle<JSReceiver> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetProperty(*key, *value, attributes, strict_mode),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetProperty(Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
@ -303,16 +256,6 @@ Handle<Object> ForceSetProperty(Handle<JSObject> object,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetNormalizedProperty(*key, *value, details),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
|
||||
Handle<Object> key) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
@ -322,30 +265,6 @@ Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetLocalPropertyIgnoreAttributes(
|
||||
Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes) {
|
||||
CALL_HEAP_FUNCTION(
|
||||
object->GetIsolate(),
|
||||
object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
void SetLocalPropertyNoThrow(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
ASSERT(!isolate->has_pending_exception());
|
||||
CHECK(!SetLocalPropertyIgnoreAttributes(
|
||||
object, key, value, attributes).is_null());
|
||||
CHECK(!isolate->has_pending_exception());
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
@ -389,12 +308,6 @@ Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> GetPrototype(Handle<Object> obj) {
|
||||
Handle<Object> result(obj->GetPrototype());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) {
|
||||
const bool skip_hidden_prototypes = false;
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
@ -402,44 +315,6 @@ Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> PreventExtensions(Handle<JSObject> object) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetHiddenProperty(Handle<JSObject> obj,
|
||||
Handle<String> key,
|
||||
Handle<Object> value) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->SetHiddenProperty(*key, *value),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
int GetIdentityHash(Handle<JSReceiver> obj) {
|
||||
CALL_AND_RETRY(obj->GetIsolate(),
|
||||
obj->GetIdentityHash(ALLOW_CREATION),
|
||||
return Smi::cast(__object__)->value(),
|
||||
return 0);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> DeleteElement(Handle<JSObject> obj,
|
||||
uint32_t index) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->DeleteElement(index, JSObject::NORMAL_DELETION),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> DeleteProperty(Handle<JSObject> obj,
|
||||
Handle<String> prop) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
CALL_HEAP_FUNCTION(
|
||||
@ -457,43 +332,6 @@ Handle<String> SubString(Handle<String> str,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode) {
|
||||
if (object->HasExternalArrayElements()) {
|
||||
if (!value->IsSmi() && !value->IsHeapNumber() && !value->IsUndefined()) {
|
||||
bool has_exception;
|
||||
Handle<Object> number = Execution::ToNumber(value, &has_exception);
|
||||
if (has_exception) return Handle<Object>();
|
||||
value = number;
|
||||
}
|
||||
}
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetElement(index, *value, strict_mode, true),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> SetOwnElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode) {
|
||||
ASSERT(!object->HasExternalArrayElements());
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetElement(index, *value, strict_mode, false),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> TransitionElementsKind(Handle<JSObject> object,
|
||||
ElementsKind to_kind) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->TransitionElementsKind(to_kind),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<JSObject> Copy(Handle<JSObject> obj) {
|
||||
Isolate* isolate = obj->GetIsolate();
|
||||
CALL_HEAP_FUNCTION(isolate,
|
||||
|
@ -167,18 +167,6 @@ class HandleScope {
|
||||
// an object of expected type, or the handle is an error if running out
|
||||
// of space or encountering an internal error.
|
||||
|
||||
void NormalizeProperties(Handle<JSObject> object,
|
||||
PropertyNormalizationMode mode,
|
||||
int expected_additional_properties);
|
||||
Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object);
|
||||
void TransformToFastProperties(Handle<JSObject> object,
|
||||
int unused_property_fields);
|
||||
MUST_USE_RESULT Handle<NumberDictionary> NumberDictionarySet(
|
||||
Handle<NumberDictionary> dictionary,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details);
|
||||
|
||||
// Flattens a string.
|
||||
void FlattenString(Handle<String> str);
|
||||
|
||||
@ -186,12 +174,6 @@ void FlattenString(Handle<String> str);
|
||||
// string.
|
||||
Handle<String> FlattenGetString(Handle<String> str);
|
||||
|
||||
Handle<Object> SetProperty(Handle<JSReceiver> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
Handle<Object> SetProperty(Handle<Object> object,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value,
|
||||
@ -203,40 +185,9 @@ Handle<Object> ForceSetProperty(Handle<JSObject> object,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes);
|
||||
|
||||
Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details);
|
||||
|
||||
Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
|
||||
Handle<Object> key);
|
||||
|
||||
Handle<Object> SetLocalPropertyIgnoreAttributes(
|
||||
Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes);
|
||||
|
||||
// Used to set local properties on the object we totally control
|
||||
// and which therefore has no accessors and alikes.
|
||||
void SetLocalPropertyNoThrow(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes = NONE);
|
||||
|
||||
MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
Handle<Object> SetOwnElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
Handle<Object> TransitionElementsKind(Handle<JSObject> object,
|
||||
ElementsKind to_kind);
|
||||
|
||||
Handle<Object> GetProperty(Handle<JSReceiver> obj,
|
||||
const char* name);
|
||||
|
||||
@ -248,21 +199,8 @@ Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
|
||||
Handle<String> name,
|
||||
PropertyAttributes* attributes);
|
||||
|
||||
Handle<Object> GetPrototype(Handle<Object> obj);
|
||||
|
||||
Handle<Object> SetPrototype(Handle<JSObject> obj, Handle<Object> value);
|
||||
|
||||
// Sets a hidden property on an object. Returns obj on success, undefined
|
||||
// if trying to set the property on a detached proxy.
|
||||
Handle<Object> SetHiddenProperty(Handle<JSObject> obj,
|
||||
Handle<String> key,
|
||||
Handle<Object> value);
|
||||
|
||||
int GetIdentityHash(Handle<JSReceiver> obj);
|
||||
|
||||
Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
|
||||
Handle<Object> DeleteProperty(Handle<JSObject> obj, Handle<String> prop);
|
||||
|
||||
Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index);
|
||||
|
||||
Handle<JSObject> Copy(Handle<JSObject> obj);
|
||||
@ -316,7 +254,6 @@ Handle<String> SubString(Handle<String> str,
|
||||
int end,
|
||||
PretenureFlag pretenure = NOT_TENURED);
|
||||
|
||||
|
||||
// Sets the expected number of properties for the function's instances.
|
||||
void SetExpectedNofProperties(Handle<JSFunction> func, int nof);
|
||||
|
||||
@ -335,8 +272,6 @@ Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
|
||||
Handle<Object> SetPrototype(Handle<JSFunction> function,
|
||||
Handle<Object> prototype);
|
||||
|
||||
Handle<Object> PreventExtensions(Handle<JSObject> object);
|
||||
|
||||
Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table,
|
||||
Handle<Object> key);
|
||||
|
||||
|
@ -1267,7 +1267,8 @@ MaybeObject* StoreIC::Store(State state,
|
||||
// Check if the given name is an array index.
|
||||
uint32_t index;
|
||||
if (name->AsArrayIndex(&index)) {
|
||||
Handle<Object> result = SetElement(receiver, index, value, strict_mode);
|
||||
Handle<Object> result =
|
||||
JSObject::SetElement(receiver, index, value, strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate(), result);
|
||||
return *value;
|
||||
}
|
||||
@ -1644,7 +1645,8 @@ MaybeObject* KeyedStoreIC::Store(State state,
|
||||
// Check if the given name is an array index.
|
||||
uint32_t index;
|
||||
if (name->AsArrayIndex(&index)) {
|
||||
Handle<Object> result = SetElement(receiver, index, value, strict_mode);
|
||||
Handle<Object> result =
|
||||
JSObject::SetElement(receiver, index, value, strict_mode);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate(), result);
|
||||
return *value;
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
||||
frame->Summarize(&frames);
|
||||
for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
|
||||
// Create a JSObject to hold the information for the StackFrame.
|
||||
Handle<JSObject> stackFrame = factory()->NewJSObject(object_function());
|
||||
Handle<JSObject> stack_frame = factory()->NewJSObject(object_function());
|
||||
|
||||
Handle<JSFunction> fun = frames[i].function();
|
||||
Handle<Script> script(Script::cast(fun->shared()->script()));
|
||||
@ -591,16 +591,24 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
||||
// tag.
|
||||
column_offset += script->column_offset()->value();
|
||||
}
|
||||
SetLocalPropertyNoThrow(stackFrame, column_key,
|
||||
Handle<Smi>(Smi::FromInt(column_offset + 1)));
|
||||
CHECK_NOT_EMPTY_HANDLE(
|
||||
this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, column_key,
|
||||
Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE));
|
||||
}
|
||||
SetLocalPropertyNoThrow(stackFrame, line_key,
|
||||
Handle<Smi>(Smi::FromInt(line_number + 1)));
|
||||
CHECK_NOT_EMPTY_HANDLE(
|
||||
this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, line_key,
|
||||
Handle<Smi>(Smi::FromInt(line_number + 1)), NONE));
|
||||
}
|
||||
|
||||
if (options & StackTrace::kScriptName) {
|
||||
Handle<Object> script_name(script->name(), this);
|
||||
SetLocalPropertyNoThrow(stackFrame, script_key, script_name);
|
||||
CHECK_NOT_EMPTY_HANDLE(this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, script_key, script_name, NONE));
|
||||
}
|
||||
|
||||
if (options & StackTrace::kScriptNameOrSourceURL) {
|
||||
@ -616,8 +624,10 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
||||
if (caught_exception) {
|
||||
result = factory()->undefined_value();
|
||||
}
|
||||
SetLocalPropertyNoThrow(stackFrame, script_name_or_source_url_key,
|
||||
result);
|
||||
CHECK_NOT_EMPTY_HANDLE(this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, script_name_or_source_url_key,
|
||||
result, NONE));
|
||||
}
|
||||
|
||||
if (options & StackTrace::kFunctionName) {
|
||||
@ -625,23 +635,30 @@ Handle<JSArray> Isolate::CaptureCurrentStackTrace(
|
||||
if (fun_name->ToBoolean()->IsFalse()) {
|
||||
fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
|
||||
}
|
||||
SetLocalPropertyNoThrow(stackFrame, function_key, fun_name);
|
||||
CHECK_NOT_EMPTY_HANDLE(this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, function_key, fun_name, NONE));
|
||||
}
|
||||
|
||||
if (options & StackTrace::kIsEval) {
|
||||
int type = Smi::cast(script->compilation_type())->value();
|
||||
Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ?
|
||||
factory()->true_value() : factory()->false_value();
|
||||
SetLocalPropertyNoThrow(stackFrame, eval_key, is_eval);
|
||||
CHECK_NOT_EMPTY_HANDLE(this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, eval_key, is_eval, NONE));
|
||||
}
|
||||
|
||||
if (options & StackTrace::kIsConstructor) {
|
||||
Handle<Object> is_constructor = (frames[i].is_constructor()) ?
|
||||
factory()->true_value() : factory()->false_value();
|
||||
SetLocalPropertyNoThrow(stackFrame, constructor_key, is_constructor);
|
||||
CHECK_NOT_EMPTY_HANDLE(this,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
stack_frame, constructor_key,
|
||||
is_constructor, NONE));
|
||||
}
|
||||
|
||||
FixedArray::cast(stack_trace->elements())->set(frames_seen, *stackFrame);
|
||||
FixedArray::cast(stack_trace->elements())->set(frames_seen, *stack_frame);
|
||||
frames_seen++;
|
||||
}
|
||||
it.Advance();
|
||||
|
@ -122,6 +122,13 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define CHECK_NOT_EMPTY_HANDLE(isolate, call) \
|
||||
do { \
|
||||
ASSERT(!(isolate)->has_pending_exception()); \
|
||||
CHECK(!(call).is_null()); \
|
||||
CHECK(!(isolate)->has_pending_exception()); \
|
||||
} while (false)
|
||||
|
||||
#define RETURN_IF_EMPTY_HANDLE(isolate, call) \
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, Failure::Exception())
|
||||
|
||||
|
@ -303,11 +303,12 @@ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
|
||||
|
||||
uint32_t index;
|
||||
if (key->AsArrayIndex(&index)) {
|
||||
SetOwnElement(json_object, index, value, kNonStrictMode);
|
||||
JSObject::SetOwnElement(json_object, index, value, kNonStrictMode);
|
||||
} else if (key->Equals(isolate()->heap()->Proto_symbol())) {
|
||||
SetPrototype(json_object, value);
|
||||
} else {
|
||||
SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE);
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
json_object, key, value, NONE);
|
||||
}
|
||||
} while (MatchSkipWhiteSpace(','));
|
||||
if (c0_ != '}') {
|
||||
|
@ -54,7 +54,7 @@ void SetElementNonStrict(Handle<JSObject> object,
|
||||
// are element setters causing exceptions and the debugger context has none
|
||||
// of these.
|
||||
Handle<Object> no_failure;
|
||||
no_failure = SetElement(object, index, value, kNonStrictMode);
|
||||
no_failure = JSObject::SetElement(object, index, value, kNonStrictMode);
|
||||
ASSERT(!no_failure.is_null());
|
||||
USE(no_failure);
|
||||
}
|
||||
|
168
src/objects.cc
168
src/objects.cc
@ -485,6 +485,16 @@ Object* JSObject::SetNormalizedProperty(LookupResult* result, Object* value) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::SetNormalizedProperty(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetNormalizedProperty(*key, *value, details),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::SetNormalizedProperty(String* name,
|
||||
Object* value,
|
||||
PropertyDetails details) {
|
||||
@ -1961,6 +1971,17 @@ MaybeObject* JSObject::SetPropertyWithInterceptor(
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSReceiver::SetProperty(Handle<JSReceiver> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetProperty(*key, *value, attributes, strict_mode),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSReceiver::SetProperty(String* name,
|
||||
Object* value,
|
||||
PropertyAttributes attributes,
|
||||
@ -3024,6 +3045,18 @@ MaybeObject* JSObject::SetPropertyForResult(LookupResult* result,
|
||||
// Note that this method cannot be used to set the prototype of a function
|
||||
// because ConvertDescriptorToField() which is called in "case CALLBACKS:"
|
||||
// doesn't handle function prototypes correctly.
|
||||
Handle<Object> JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes) {
|
||||
CALL_HEAP_FUNCTION(
|
||||
object->GetIsolate(),
|
||||
object->SetLocalPropertyIgnoreAttributes(*key, *value, attributes),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
String* name,
|
||||
Object* value,
|
||||
@ -3314,6 +3347,15 @@ MaybeObject* JSObject::UpdateMapCodeCache(String* name, Code* code) {
|
||||
}
|
||||
|
||||
|
||||
void JSObject::NormalizeProperties(Handle<JSObject> object,
|
||||
PropertyNormalizationMode mode,
|
||||
int expected_additional_properties) {
|
||||
CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
|
||||
object->NormalizeProperties(
|
||||
mode, expected_additional_properties));
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
|
||||
int expected_additional_properties) {
|
||||
if (!HasFastProperties()) return this;
|
||||
@ -3436,6 +3478,14 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
|
||||
}
|
||||
|
||||
|
||||
void JSObject::TransformToFastProperties(Handle<JSObject> object,
|
||||
int unused_property_fields) {
|
||||
CALL_HEAP_FUNCTION_VOID(
|
||||
object->GetIsolate(),
|
||||
object->TransformToFastProperties(unused_property_fields));
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) {
|
||||
if (HasFastProperties()) return this;
|
||||
ASSERT(!IsGlobalObject());
|
||||
@ -3444,6 +3494,12 @@ MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) {
|
||||
}
|
||||
|
||||
|
||||
Handle<NumberDictionary> JSObject::NormalizeElements(Handle<JSObject> object) {
|
||||
CALL_HEAP_FUNCTION(
|
||||
object->GetIsolate(), object->NormalizeElements(), NumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::NormalizeElements() {
|
||||
ASSERT(!HasExternalArrayElements());
|
||||
|
||||
@ -3560,6 +3616,14 @@ MaybeObject* JSObject::SetIdentityHash(Object* hash, CreationFlag flag) {
|
||||
}
|
||||
|
||||
|
||||
int JSObject::GetIdentityHash(Handle<JSObject> obj) {
|
||||
CALL_AND_RETRY(obj->GetIsolate(),
|
||||
obj->GetIdentityHash(ALLOW_CREATION),
|
||||
return Smi::cast(__object__)->value(),
|
||||
return 0);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::GetIdentityHash(CreationFlag flag) {
|
||||
Object* stored_value = GetHiddenProperty(GetHeap()->identity_hash_symbol());
|
||||
if (stored_value->IsSmi()) return stored_value;
|
||||
@ -3612,6 +3676,15 @@ Object* JSObject::GetHiddenProperty(String* key) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::SetHiddenProperty(Handle<JSObject> obj,
|
||||
Handle<String> key,
|
||||
Handle<Object> value) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->SetHiddenProperty(*key, *value),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::SetHiddenProperty(String* key, Object* value) {
|
||||
if (IsJSGlobalProxy()) {
|
||||
// For a proxy, use the prototype as target object.
|
||||
@ -3839,6 +3912,14 @@ MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::DeleteElement(Handle<JSObject> obj,
|
||||
uint32_t index) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->DeleteElement(index, JSObject::NORMAL_DELETION),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
|
||||
Isolate* isolate = GetIsolate();
|
||||
// Check access rights if needed.
|
||||
@ -3867,19 +3948,11 @@ MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) {
|
||||
if (IsJSProxy()) {
|
||||
return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode);
|
||||
}
|
||||
return JSObject::cast(this)->DeleteProperty(name, mode);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
|
||||
if (IsJSProxy()) {
|
||||
return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
|
||||
}
|
||||
return JSObject::cast(this)->DeleteElement(index, mode);
|
||||
Handle<Object> JSObject::DeleteProperty(Handle<JSObject> obj,
|
||||
Handle<String> prop) {
|
||||
CALL_HEAP_FUNCTION(obj->GetIsolate(),
|
||||
obj->DeleteProperty(*prop, JSObject::NORMAL_DELETION),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
@ -3940,6 +4013,22 @@ MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSReceiver::DeleteElement(uint32_t index, DeleteMode mode) {
|
||||
if (IsJSProxy()) {
|
||||
return JSProxy::cast(this)->DeleteElementWithHandler(index, mode);
|
||||
}
|
||||
return JSObject::cast(this)->DeleteElement(index, mode);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSReceiver::DeleteProperty(String* name, DeleteMode mode) {
|
||||
if (IsJSProxy()) {
|
||||
return JSProxy::cast(this)->DeletePropertyWithHandler(name, mode);
|
||||
}
|
||||
return JSObject::cast(this)->DeleteProperty(name, mode);
|
||||
}
|
||||
|
||||
|
||||
bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
|
||||
ElementsKind kind,
|
||||
Object* object) {
|
||||
@ -4066,6 +4155,11 @@ bool JSObject::ReferencesObject(Object* obj) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::PreventExtensions(Handle<JSObject> object) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(), object->PreventExtensions(), Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::PreventExtensions() {
|
||||
Isolate* isolate = GetIsolate();
|
||||
if (IsAccessCheckNeeded() &&
|
||||
@ -9388,6 +9482,35 @@ MaybeObject* JSReceiver::SetElement(uint32_t index,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode) {
|
||||
ASSERT(!object->HasExternalArrayElements());
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetElement(index, *value, strict_mode, false),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::SetElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode) {
|
||||
if (object->HasExternalArrayElements()) {
|
||||
if (!value->IsSmi() && !value->IsHeapNumber() && !value->IsUndefined()) {
|
||||
bool has_exception;
|
||||
Handle<Object> number = Execution::ToNumber(value, &has_exception);
|
||||
if (has_exception) return Handle<Object>();
|
||||
value = number;
|
||||
}
|
||||
}
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->SetElement(index, *value, strict_mode, true),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::SetElement(uint32_t index,
|
||||
Object* value,
|
||||
StrictModeFlag strict_mode,
|
||||
@ -9510,6 +9633,14 @@ MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> JSObject::TransitionElementsKind(Handle<JSObject> object,
|
||||
ElementsKind to_kind) {
|
||||
CALL_HEAP_FUNCTION(object->GetIsolate(),
|
||||
object->TransitionElementsKind(to_kind),
|
||||
Object);
|
||||
}
|
||||
|
||||
|
||||
MUST_USE_RESULT MaybeObject* JSObject::TransitionElementsKind(
|
||||
ElementsKind to_kind) {
|
||||
ElementsKind from_kind = map()->elements_kind();
|
||||
@ -11964,6 +12095,17 @@ MaybeObject* NumberDictionary::AtNumberPut(uint32_t key, Object* value) {
|
||||
}
|
||||
|
||||
|
||||
Handle<NumberDictionary> NumberDictionary::Set(
|
||||
Handle<NumberDictionary> dictionary,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details) {
|
||||
CALL_HEAP_FUNCTION(dictionary->GetIsolate(),
|
||||
dictionary->Set(index, *value, details),
|
||||
NumberDictionary);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* NumberDictionary::Set(uint32_t key,
|
||||
Object* value,
|
||||
PropertyDetails details) {
|
||||
|
@ -1342,6 +1342,11 @@ class JSReceiver: public HeapObject {
|
||||
// Casting.
|
||||
static inline JSReceiver* cast(Object* obj);
|
||||
|
||||
static Handle<Object> SetProperty(Handle<JSReceiver> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode);
|
||||
// Can cause GC.
|
||||
MUST_USE_RESULT MaybeObject* SetProperty(String* key,
|
||||
Object* value,
|
||||
@ -1521,6 +1526,14 @@ class JSObject: public JSReceiver {
|
||||
Object* value,
|
||||
PropertyAttributes attributes,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
static Handle<Object> SetLocalPropertyIgnoreAttributes(
|
||||
Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attributes);
|
||||
|
||||
// Can cause GC.
|
||||
MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
|
||||
String* key,
|
||||
Object* value,
|
||||
@ -1536,6 +1549,11 @@ class JSObject: public JSReceiver {
|
||||
|
||||
// Sets the property value in a normalized object given (key, value, details).
|
||||
// Handles the special representation of JS global objects.
|
||||
static Handle<Object> SetNormalizedProperty(Handle<JSObject> object,
|
||||
Handle<String> key,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name,
|
||||
Object* value,
|
||||
PropertyDetails details);
|
||||
@ -1605,8 +1623,11 @@ class JSObject: public JSReceiver {
|
||||
// hidden properties.
|
||||
|
||||
// Sets a hidden property on this object. Returns this object if successful,
|
||||
// undefined if called on a detached proxy, and a failure if a GC
|
||||
// is required
|
||||
// undefined if called on a detached proxy.
|
||||
static Handle<Object> SetHiddenProperty(Handle<JSObject> obj,
|
||||
Handle<String> key,
|
||||
Handle<Object> value);
|
||||
// Returns a failure if a GC is required.
|
||||
MaybeObject* SetHiddenProperty(String* key, Object* value);
|
||||
// Gets the value of a hidden property with the given key. Returns undefined
|
||||
// if the property doesn't exist (or if called on a detached proxy),
|
||||
@ -1618,10 +1639,15 @@ class JSObject: public JSReceiver {
|
||||
// Returns true if the object has a property with the hidden symbol as name.
|
||||
bool HasHiddenProperties();
|
||||
|
||||
static int GetIdentityHash(Handle<JSObject> obj);
|
||||
MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
|
||||
MUST_USE_RESULT MaybeObject* SetIdentityHash(Object* hash, CreationFlag flag);
|
||||
|
||||
static Handle<Object> DeleteProperty(Handle<JSObject> obj,
|
||||
Handle<String> name);
|
||||
MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
|
||||
|
||||
static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
|
||||
MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
|
||||
|
||||
inline void ValidateSmiOnlyElements();
|
||||
@ -1701,7 +1727,18 @@ class JSObject: public JSReceiver {
|
||||
StrictModeFlag strict_mode,
|
||||
bool check_prototype = true);
|
||||
|
||||
// Set the index'th array element.
|
||||
|
||||
static Handle<Object> SetOwnElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
// Empty handle is returned if the element cannot be set to the given value.
|
||||
static MUST_USE_RESULT Handle<Object> SetElement(Handle<JSObject> object,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
StrictModeFlag strict_mode);
|
||||
|
||||
// A Failure object is returned if GC is needed.
|
||||
MUST_USE_RESULT MaybeObject* SetElement(uint32_t index,
|
||||
Object* value,
|
||||
@ -1811,6 +1848,9 @@ class JSObject: public JSReceiver {
|
||||
MUST_USE_RESULT MaybeObject* GetElementsTransitionMap(
|
||||
ElementsKind elements_kind);
|
||||
|
||||
static Handle<Object> TransitionElementsKind(Handle<JSObject> object,
|
||||
ElementsKind to_kind);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* TransitionElementsKind(ElementsKind to_kind);
|
||||
|
||||
// Converts a descriptor of any other type to a real field,
|
||||
@ -1851,12 +1891,18 @@ class JSObject: public JSReceiver {
|
||||
// representation. If the object is expected to have additional properties
|
||||
// added this number can be indicated to have the backing store allocated to
|
||||
// an initial capacity for holding these properties.
|
||||
static void NormalizeProperties(Handle<JSObject> object,
|
||||
PropertyNormalizationMode mode,
|
||||
int expected_additional_properties);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* NormalizeProperties(
|
||||
PropertyNormalizationMode mode,
|
||||
int expected_additional_properties);
|
||||
|
||||
// Convert and update the elements backing store to be a NumberDictionary
|
||||
// dictionary. Returns the backing after conversion.
|
||||
static Handle<NumberDictionary> NormalizeElements(Handle<JSObject> object);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* NormalizeElements();
|
||||
|
||||
static void UpdateMapCodeCache(Handle<JSObject> object,
|
||||
@ -1867,6 +1913,9 @@ class JSObject: public JSReceiver {
|
||||
|
||||
// Transform slow named properties to fast variants.
|
||||
// Returns failure if allocation failed.
|
||||
static void TransformToFastProperties(Handle<JSObject> object,
|
||||
int unused_property_fields);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* TransformToFastProperties(
|
||||
int unused_property_fields);
|
||||
|
||||
@ -1898,6 +1947,7 @@ class JSObject: public JSReceiver {
|
||||
static inline JSObject* cast(Object* obj);
|
||||
|
||||
// Disalow further properties to be added to the object.
|
||||
static Handle<Object> PreventExtensions(Handle<JSObject> object);
|
||||
MUST_USE_RESULT MaybeObject* PreventExtensions();
|
||||
|
||||
|
||||
@ -2973,6 +3023,13 @@ class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> {
|
||||
PropertyDetails details);
|
||||
|
||||
// Set an existing entry or add a new one if needed.
|
||||
// Return the updated dictionary.
|
||||
MUST_USE_RESULT static Handle<NumberDictionary> Set(
|
||||
Handle<NumberDictionary> dictionary,
|
||||
uint32_t index,
|
||||
Handle<Object> value,
|
||||
PropertyDetails details);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* Set(uint32_t key,
|
||||
Object* value,
|
||||
PropertyDetails details);
|
||||
|
151
src/runtime.cc
151
src/runtime.cc
@ -355,7 +355,7 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
||||
Handle<JSObject> boilerplate = isolate->factory()->NewJSObjectFromMap(map);
|
||||
|
||||
// Normalize the elements of the boilerplate to save space if needed.
|
||||
if (!should_have_fast_elements) NormalizeElements(boilerplate);
|
||||
if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate);
|
||||
|
||||
// Add the constant properties to the boilerplate.
|
||||
int length = constant_properties->length();
|
||||
@ -365,7 +365,8 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
||||
// Normalize the properties of object to avoid n^2 behavior
|
||||
// when extending the object multiple properties. Indicate the number of
|
||||
// properties to be added.
|
||||
NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2);
|
||||
JSObject::NormalizeProperties(
|
||||
boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2);
|
||||
}
|
||||
|
||||
for (int index = 0; index < length; index +=2) {
|
||||
@ -383,22 +384,18 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
||||
if (key->IsSymbol()) {
|
||||
if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
|
||||
// Array index as string (uint32).
|
||||
result = SetOwnElement(boilerplate,
|
||||
element_index,
|
||||
value,
|
||||
kNonStrictMode);
|
||||
result = JSObject::SetOwnElement(
|
||||
boilerplate, element_index, value, kNonStrictMode);
|
||||
} else {
|
||||
Handle<String> name(String::cast(*key));
|
||||
ASSERT(!name->AsArrayIndex(&element_index));
|
||||
result = SetLocalPropertyIgnoreAttributes(boilerplate, name,
|
||||
value, NONE);
|
||||
result = JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
boilerplate, name, value, NONE);
|
||||
}
|
||||
} else if (key->ToArrayIndex(&element_index)) {
|
||||
// Array index (uint32).
|
||||
result = SetOwnElement(boilerplate,
|
||||
element_index,
|
||||
value,
|
||||
kNonStrictMode);
|
||||
result = JSObject::SetOwnElement(
|
||||
boilerplate, element_index, value, kNonStrictMode);
|
||||
} else {
|
||||
// Non-uint32 number.
|
||||
ASSERT(key->IsNumber());
|
||||
@ -408,8 +405,8 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
||||
const char* str = DoubleToCString(num, buffer);
|
||||
Handle<String> name =
|
||||
isolate->factory()->NewStringFromAscii(CStrVector(str));
|
||||
result = SetLocalPropertyIgnoreAttributes(boilerplate, name,
|
||||
value, NONE);
|
||||
result = JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
boilerplate, name, value, NONE);
|
||||
}
|
||||
// If setting the property on the boilerplate throws an
|
||||
// exception, the exception is converted to an empty handle in
|
||||
@ -423,8 +420,8 @@ static Handle<Object> CreateObjectLiteralBoilerplate(
|
||||
// computed properties have been assigned so that we can generate
|
||||
// constant function properties.
|
||||
if (should_transform && !has_function_literal) {
|
||||
TransformToFastProperties(boilerplate,
|
||||
boilerplate->map()->unused_property_fields());
|
||||
JSObject::TransformToFastProperties(
|
||||
boilerplate, boilerplate->map()->unused_property_fields());
|
||||
}
|
||||
|
||||
return boilerplate;
|
||||
@ -1335,21 +1332,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) {
|
||||
}
|
||||
PropertyAttributes attributes = static_cast<PropertyAttributes>(attr);
|
||||
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetLocalPropertyIgnoreAttributes(global,
|
||||
name,
|
||||
value,
|
||||
attributes));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(global, name, value,
|
||||
attributes));
|
||||
} else {
|
||||
LanguageMode language_mode = DeclareGlobalsLanguageMode::decode(flags);
|
||||
StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE)
|
||||
? kNonStrictMode : kStrictMode;
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetProperty(global,
|
||||
name,
|
||||
value,
|
||||
static_cast<PropertyAttributes>(attr),
|
||||
strict_mode_flag));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
JSReceiver::SetProperty(global, name, value,
|
||||
static_cast<PropertyAttributes>(attr),
|
||||
strict_mode_flag));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1403,7 +1398,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
|
||||
Handle<JSObject> object = Handle<JSObject>::cast(holder);
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
SetProperty(object, name, initial_value, mode, kNonStrictMode));
|
||||
JSReceiver::SetProperty(object, name, initial_value, mode,
|
||||
kNonStrictMode));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1443,9 +1439,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
|
||||
return ThrowRedeclarationError(isolate, "const", name);
|
||||
}
|
||||
}
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetProperty(object, name, value, mode,
|
||||
kNonStrictMode));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode));
|
||||
}
|
||||
|
||||
return isolate->heap()->undefined_value();
|
||||
@ -1554,12 +1550,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) {
|
||||
// property through an interceptor and only do it if it's
|
||||
// uninitialized, e.g. the hole. Nirk...
|
||||
// Passing non-strict mode because the property is writable.
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetProperty(global,
|
||||
name,
|
||||
value,
|
||||
attributes,
|
||||
kNonStrictMode));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
JSReceiver::SetProperty(global, name, value, attributes,
|
||||
kNonStrictMode));
|
||||
return *value;
|
||||
}
|
||||
|
||||
@ -1629,7 +1623,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) {
|
||||
// Strict mode not needed (const disallowed in strict mode).
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
SetProperty(global, name, value, NONE, kNonStrictMode));
|
||||
JSReceiver::SetProperty(global, name, value, NONE, kNonStrictMode));
|
||||
return *value;
|
||||
}
|
||||
|
||||
@ -1681,7 +1675,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) {
|
||||
// Strict mode not needed (const disallowed in strict mode).
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
SetProperty(object, name, value, attributes, kNonStrictMode));
|
||||
JSReceiver::SetProperty(object, name, value, attributes,
|
||||
kNonStrictMode));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1696,7 +1691,7 @@ RUNTIME_FUNCTION(MaybeObject*,
|
||||
CONVERT_ARG_CHECKED(JSObject, object, 0);
|
||||
CONVERT_SMI_ARG_CHECKED(properties, 1);
|
||||
if (object->HasFastProperties()) {
|
||||
NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties);
|
||||
JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties);
|
||||
}
|
||||
return *object;
|
||||
}
|
||||
@ -1852,7 +1847,7 @@ static Handle<JSFunction> InstallBuiltin(Isolate* isolate,
|
||||
code,
|
||||
false);
|
||||
optimized->shared()->DontAdaptArguments();
|
||||
SetProperty(holder, key, optimized, NONE, kStrictMode);
|
||||
JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode);
|
||||
return optimized;
|
||||
}
|
||||
|
||||
@ -4066,8 +4061,7 @@ MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate,
|
||||
}
|
||||
|
||||
if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
|
||||
Handle<Object> prototype = GetPrototype(object);
|
||||
return prototype->GetElement(index);
|
||||
return object->GetPrototype()->GetElement(index);
|
||||
}
|
||||
|
||||
return object->GetElement(index);
|
||||
@ -4134,8 +4128,8 @@ MaybeObject* TransitionElements(Handle<Object> object,
|
||||
ElementsKind from_kind =
|
||||
Handle<JSObject>::cast(object)->map()->elements_kind();
|
||||
if (Map::IsValidElementsTransition(from_kind, to_kind)) {
|
||||
Handle<Object> result =
|
||||
TransitionElementsKind(Handle<JSObject>::cast(object), to_kind);
|
||||
Handle<Object> result = JSObject::TransitionElementsKind(
|
||||
Handle<JSObject>::cast(object), to_kind);
|
||||
if (result.is_null()) return isolate->ThrowIllegalOperation();
|
||||
return *result;
|
||||
}
|
||||
@ -4307,12 +4301,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
||||
return isolate->Throw(*error);
|
||||
}
|
||||
|
||||
Handle<NumberDictionary> dictionary = NormalizeElements(js_object);
|
||||
Handle<NumberDictionary> dictionary =
|
||||
JSObject::NormalizeElements(js_object);
|
||||
// Make sure that we never go back to fast case.
|
||||
dictionary->set_requires_slow_elements();
|
||||
PropertyDetails details = PropertyDetails(attr, NORMAL);
|
||||
Handle<NumberDictionary> extended_dictionary =
|
||||
NumberDictionarySet(dictionary, index, obj_value, details);
|
||||
NumberDictionary::Set(dictionary, index, obj_value, details);
|
||||
if (*extended_dictionary != *dictionary) {
|
||||
if (js_object->GetElementsKind() == NON_STRICT_ARGUMENTS_ELEMENTS) {
|
||||
FixedArray::cast(js_object->elements())->set(1, *extended_dictionary);
|
||||
@ -4362,7 +4357,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
|
||||
// we don't have to check for null.
|
||||
js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype()));
|
||||
}
|
||||
NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
|
||||
JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
|
||||
// Use IgnoreAttributes version since a readonly property may be
|
||||
// overridden and SetProperty does not allow this.
|
||||
return js_object->SetLocalPropertyIgnoreAttributes(*name,
|
||||
@ -4387,12 +4382,12 @@ static MaybeObject* NormalizeObjectSetElement(Isolate* isolate,
|
||||
Handle<Object> value,
|
||||
PropertyAttributes attr) {
|
||||
// Normalize the elements to enable attributes on the property.
|
||||
Handle<NumberDictionary> dictionary = NormalizeElements(js_object);
|
||||
Handle<NumberDictionary> dictionary = JSObject::NormalizeElements(js_object);
|
||||
// Make sure that we never go back to fast case.
|
||||
dictionary->set_requires_slow_elements();
|
||||
PropertyDetails details = PropertyDetails(attr, NORMAL);
|
||||
Handle<NumberDictionary> extended_dictionary =
|
||||
NumberDictionarySet(dictionary, index, value, details);
|
||||
NumberDictionary::Set(dictionary, index, value, details);
|
||||
if (*extended_dictionary != *dictionary) {
|
||||
js_object->set_elements(*extended_dictionary);
|
||||
}
|
||||
@ -4447,7 +4442,8 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
return NormalizeObjectSetElement(isolate, js_object, index, value, attr);
|
||||
}
|
||||
|
||||
Handle<Object> result = SetElement(js_object, index, value, strict_mode);
|
||||
Handle<Object> result =
|
||||
JSObject::SetElement(js_object, index, value, strict_mode);
|
||||
if (result.is_null()) return Failure::Exception();
|
||||
return *value;
|
||||
}
|
||||
@ -4462,11 +4458,13 @@ MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
|
||||
value,
|
||||
attr);
|
||||
}
|
||||
result = SetElement(js_object, index, value, strict_mode);
|
||||
result =
|
||||
JSObject::SetElement(js_object, index, value, strict_mode);
|
||||
} else {
|
||||
Handle<String> key_string = Handle<String>::cast(key);
|
||||
key_string->TryFlatten();
|
||||
result = SetProperty(js_object, key_string, value, attr, strict_mode);
|
||||
result = JSReceiver::SetProperty(
|
||||
js_object, key_string, value, attr, strict_mode);
|
||||
}
|
||||
if (result.is_null()) return Failure::Exception();
|
||||
return *value;
|
||||
@ -4655,8 +4653,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
|
||||
|
||||
if (value->IsNumber()) {
|
||||
ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS);
|
||||
TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
|
||||
TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS);
|
||||
JSObject::TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS);
|
||||
JSObject::TransitionElementsKind(boilerplate_object, FAST_DOUBLE_ELEMENTS);
|
||||
ASSERT(object->GetElementsKind() == FAST_DOUBLE_ELEMENTS);
|
||||
FixedDoubleArray* double_array =
|
||||
FixedDoubleArray::cast(object->elements());
|
||||
@ -4665,8 +4663,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) {
|
||||
} else {
|
||||
ASSERT(elements_kind == FAST_SMI_ONLY_ELEMENTS ||
|
||||
elements_kind == FAST_DOUBLE_ELEMENTS);
|
||||
TransitionElementsKind(object, FAST_ELEMENTS);
|
||||
TransitionElementsKind(boilerplate_object, FAST_ELEMENTS);
|
||||
JSObject::TransitionElementsKind(object, FAST_ELEMENTS);
|
||||
JSObject::TransitionElementsKind(boilerplate_object, FAST_ELEMENTS);
|
||||
FixedArray* object_array =
|
||||
FixedArray::cast(object->elements());
|
||||
object_array->set(store_index, *value);
|
||||
@ -5144,31 +5142,20 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) {
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
ASSERT(args.length() == 1);
|
||||
Handle<Object> object = args.at<Object>(0);
|
||||
if (object->IsJSObject()) {
|
||||
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
|
||||
if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) {
|
||||
MaybeObject* ok = js_object->TransformToFastProperties(0);
|
||||
if (ok->IsRetryAfterGC()) return ok;
|
||||
}
|
||||
}
|
||||
return *object;
|
||||
Object* object = args[0];
|
||||
return (object->IsJSObject() && !object->IsGlobalObject())
|
||||
? JSObject::cast(object)->TransformToFastProperties(0)
|
||||
: object;
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
ASSERT(args.length() == 1);
|
||||
Handle<Object> object = args.at<Object>(0);
|
||||
if (object->IsJSObject() && !object->IsJSGlobalProxy()) {
|
||||
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
|
||||
NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
|
||||
}
|
||||
return *object;
|
||||
Object* obj = args[0];
|
||||
return (obj->IsJSObject() && !obj->IsJSGlobalProxy())
|
||||
? JSObject::cast(obj)->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0)
|
||||
: obj;
|
||||
}
|
||||
|
||||
|
||||
@ -9133,7 +9120,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
|
||||
(object->GetLocalPropertyAttribute(*name) == ABSENT)) {
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate,
|
||||
SetProperty(object, name, value, NONE, strict_mode));
|
||||
JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
|
||||
} else if (strict_mode == kStrictMode && (attributes & READ_ONLY) != 0) {
|
||||
// Setting read only property in strict mode.
|
||||
Handle<Object> error =
|
||||
@ -10049,7 +10036,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) {
|
||||
// FAST_ELEMENTS.
|
||||
if (array->HasFastDoubleElements()) {
|
||||
array = Handle<JSArray>::cast(
|
||||
TransitionElementsKind(array, FAST_ELEMENTS));
|
||||
JSObject::TransitionElementsKind(array, FAST_ELEMENTS));
|
||||
}
|
||||
length_estimate =
|
||||
static_cast<uint32_t>(array->length()->Number());
|
||||
@ -10209,10 +10196,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SwapElements) {
|
||||
Handle<Object> tmp2 = Object::GetElement(jsobject, index2);
|
||||
RETURN_IF_EMPTY_HANDLE(isolate, tmp2);
|
||||
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetElement(jsobject, index1, tmp2, kStrictMode));
|
||||
RETURN_IF_EMPTY_HANDLE(isolate,
|
||||
SetElement(jsobject, index2, tmp1, kStrictMode));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate, JSObject::SetElement(jsobject, index1, tmp2, kStrictMode));
|
||||
RETURN_IF_EMPTY_HANDLE(
|
||||
isolate, JSObject::SetElement(jsobject, index2, tmp1, kStrictMode));
|
||||
|
||||
return isolate->heap()->undefined_value();
|
||||
}
|
||||
|
@ -679,10 +679,10 @@ Handle<Code> StubCache::ComputeCallGlobal(int argc,
|
||||
|
||||
static void FillCache(Isolate* isolate, Handle<Code> code) {
|
||||
Handle<NumberDictionary> dictionary =
|
||||
NumberDictionarySet(isolate->factory()->non_monomorphic_cache(),
|
||||
code->flags(),
|
||||
code,
|
||||
PropertyDetails(NONE, NORMAL));
|
||||
NumberDictionary::Set(isolate->factory()->non_monomorphic_cache(),
|
||||
code->flags(),
|
||||
code,
|
||||
PropertyDetails(NONE, NORMAL));
|
||||
isolate->heap()->public_set_non_monomorphic_cache(*dictionary);
|
||||
}
|
||||
|
||||
|
@ -12269,18 +12269,18 @@ THREADED_TEST(PixelArray) {
|
||||
|
||||
i::Handle<i::Smi> value(i::Smi::FromInt(2));
|
||||
i::Handle<i::Object> no_failure;
|
||||
no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
no_failure = i::JSObject::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
ASSERT(!no_failure.is_null());
|
||||
i::USE(no_failure);
|
||||
CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
|
||||
*value.location() = i::Smi::FromInt(256);
|
||||
no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
no_failure = i::JSObject::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
ASSERT(!no_failure.is_null());
|
||||
i::USE(no_failure);
|
||||
CHECK_EQ(255,
|
||||
i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
|
||||
*value.location() = i::Smi::FromInt(-1);
|
||||
no_failure = i::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
no_failure = i::JSObject::SetElement(jsobj, 1, value, i::kNonStrictMode);
|
||||
ASSERT(!no_failure.is_null());
|
||||
i::USE(no_failure);
|
||||
CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
|
||||
|
Loading…
Reference in New Issue
Block a user