| Index: src/accessors.cc
|
| diff --git a/src/accessors.cc b/src/accessors.cc
|
| index 50232661c1976d67e61fe7855fd19e16d186197f..eb8be5f66abbef2704e00a8b20e8e45c582443f6 100644
|
| --- a/src/accessors.cc
|
| +++ b/src/accessors.cc
|
| @@ -148,45 +148,49 @@ MaybeObject* Accessors::ArrayGetLength(Isolate* isolate,
|
|
|
|
|
| // The helper function will 'flatten' Number objects.
|
| -Object* Accessors::FlattenNumber(Isolate* isolate, Object* value) {
|
| +Handle<Object> Accessors::FlattenNumber(Isolate* isolate,
|
| + Handle<Object> value) {
|
| if (value->IsNumber() || !value->IsJSValue()) return value;
|
| - JSValue* wrapper = JSValue::cast(value);
|
| + Handle<JSValue> wrapper = Handle<JSValue>::cast(value);
|
| ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()->
|
| has_initial_map());
|
| - Map* number_map = isolate->context()->native_context()->
|
| - number_function()->initial_map();
|
| - if (wrapper->map() == number_map) return wrapper->value();
|
| + if (wrapper->map() ==
|
| + isolate->context()->native_context()->number_function()->initial_map()) {
|
| + return handle(wrapper->value(), isolate);
|
| + }
|
| +
|
| return value;
|
| }
|
|
|
|
|
| MaybeObject* Accessors::ArraySetLength(Isolate* isolate,
|
| - JSObject* object,
|
| - Object* value,
|
| + JSObject* object_raw,
|
| + Object* value_raw,
|
| void*) {
|
| + HandleScope scope(isolate);
|
| + Handle<JSObject> object(object_raw, isolate);
|
| + Handle<Object> value(value_raw, isolate);
|
| +
|
| // This means one of the object's prototypes is a JSArray and the
|
| // object does not have a 'length' property. Calling SetProperty
|
| // causes an infinite loop.
|
| if (!object->IsJSArray()) {
|
| - return object->SetLocalPropertyIgnoreAttributesTrampoline(
|
| - isolate->heap()->length_string(), value, NONE);
|
| + Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(object,
|
| + isolate->factory()->length_string(), value, NONE);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| }
|
|
|
| value = FlattenNumber(isolate, value);
|
|
|
| - // Need to call methods that may trigger GC.
|
| - HandleScope scope(isolate);
|
| -
|
| - // Protect raw pointers.
|
| - Handle<JSArray> array_handle(JSArray::cast(object), isolate);
|
| - Handle<Object> value_handle(value, isolate);
|
| + Handle<JSArray> array_handle = Handle<JSArray>::cast(object);
|
|
|
| bool has_exception;
|
| Handle<Object> uint32_v =
|
| - Execution::ToUint32(isolate, value_handle, &has_exception);
|
| + Execution::ToUint32(isolate, value, &has_exception);
|
| if (has_exception) return Failure::Exception();
|
| Handle<Object> number_v =
|
| - Execution::ToNumber(isolate, value_handle, &has_exception);
|
| + Execution::ToNumber(isolate, value, &has_exception);
|
| if (has_exception) return Failure::Exception();
|
|
|
| if (uint32_v->Number() == number_v->Number()) {
|
| @@ -578,26 +582,28 @@ MaybeObject* Accessors::FunctionGetPrototype(Isolate* isolate,
|
|
|
|
|
| MaybeObject* Accessors::FunctionSetPrototype(Isolate* isolate,
|
| - JSObject* object,
|
| + JSObject* object_raw,
|
| Object* value_raw,
|
| void*) {
|
| - Heap* heap = isolate->heap();
|
| - JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object);
|
| - if (function_raw == NULL) return heap->undefined_value();
|
| - if (!function_raw->should_have_prototype()) {
|
| - // Since we hit this accessor, object will have no prototype property.
|
| - return object->SetLocalPropertyIgnoreAttributesTrampoline(
|
| - heap->prototype_string(), value_raw, NONE);
|
| - }
|
| + JSFunction* function_raw = FindInstanceOf<JSFunction>(isolate, object_raw);
|
| + if (function_raw == NULL) return isolate->heap()->undefined_value();
|
|
|
| HandleScope scope(isolate);
|
| Handle<JSFunction> function(function_raw, isolate);
|
| + Handle<JSObject> object(object_raw, isolate);
|
| Handle<Object> value(value_raw, isolate);
|
| + if (!function->should_have_prototype()) {
|
| + // Since we hit this accessor, object will have no prototype property.
|
| + Handle<Object> result = JSObject::SetLocalPropertyIgnoreAttributes(object,
|
| + isolate->factory()->prototype_string(), value, NONE);
|
| + RETURN_IF_EMPTY_HANDLE(isolate, result);
|
| + return *result;
|
| + }
|
|
|
| Handle<Object> old_value;
|
| bool is_observed =
|
| FLAG_harmony_observation &&
|
| - *function == object &&
|
| + *function == *object &&
|
| function->map()->is_observed();
|
| if (is_observed) {
|
| if (function->has_prototype())
|
|
|