Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index 4f340855e907380dc0fa7ceda43a18219fa13227..ef0a6333fb2b36db652e52480d05abdccbbc654d 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -10717,63 +10717,45 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { |
| } |
| -static MaybeObject* DebugLookupResultValue(Heap* heap, |
| - Object* receiver, |
| - Name* name, |
| - LookupResult* result, |
| - bool* caught_exception) { |
| - Object* value; |
| - if (result->IsTransition()) return heap->undefined_value(); |
| +static MaybeHandle<Object> DebugLookupResultValue(Isolate* isolate, |
| + Handle<Object> receiver, |
| + Handle<Name> name, |
| + LookupResult* result) { |
| + Handle<Object> value = isolate->factory()->undefined_value(); |
| switch (result->type()) { |
| - case NORMAL: |
| - value = result->holder()->GetNormalizedProperty(result); |
| - if (value->IsTheHole()) { |
| - return heap->undefined_value(); |
| - } |
| - return value; |
| - case FIELD: { |
| - Object* value; |
| - MaybeObject* maybe_value = |
| - JSObject::cast(result->holder())->FastPropertyAt( |
| - result->representation(), |
| - result->GetFieldIndex().field_index()); |
| - if (!maybe_value->To(&value)) return maybe_value; |
| - if (value->IsTheHole()) { |
| - return heap->undefined_value(); |
| - } |
| - return value; |
| + case NORMAL: { |
| + value = JSObject::GetNormalizedProperty( |
| + handle(result->holder(), isolate), result); |
| + break; |
| } |
| + case FIELD: |
| + value = JSObject::FastPropertyAt(handle(result->holder(), isolate), |
| + result->representation(), |
| + result->GetFieldIndex().field_index()); |
| + break; |
| case CONSTANT: |
| - return result->GetConstant(); |
| + return handle(result->GetConstant(), isolate); |
| case CALLBACKS: { |
| - Object* structure = result->GetCallbackObject(); |
| + Handle<Object> structure(result->GetCallbackObject(), isolate); |
| if (structure->IsForeign() || structure->IsAccessorInfo()) { |
| - Isolate* isolate = heap->isolate(); |
| - HandleScope scope(isolate); |
| - MaybeHandle<Object> maybe_value = JSObject::GetPropertyWithCallback( |
| + return JSObject::GetPropertyWithCallback( |
| handle(result->holder(), isolate), |
| - handle(receiver, isolate), |
| - handle(structure, isolate), |
| - handle(name, isolate)); |
| - Handle<Object> value; |
| - if (maybe_value.ToHandle(&value)) return *value; |
| - Object* exception = heap->isolate()->pending_exception(); |
| - heap->isolate()->clear_pending_exception(); |
| - if (caught_exception != NULL) *caught_exception = true; |
| - return exception; |
| - } else { |
| - return heap->undefined_value(); |
| + receiver, |
| + handle(result->GetCallbackObject(), isolate), |
| + name); |
| } |
| + // Fall through; |
|
ulan
2014/04/14 11:25:25
"break" would be easier to read than "fall through
Yang
2014/04/14 13:12:42
Done.
|
| } |
| - case INTERCEPTOR: |
| - return heap->undefined_value(); |
| case HANDLER: |
|
ulan
2014/04/14 11:25:25
this was unreachable before.
Yang
2014/04/14 13:12:42
Handler is now again unreachable. Debugger/proxy i
|
| + case INTERCEPTOR: |
| + break; |
| case NONEXISTENT: |
| UNREACHABLE(); |
| - return heap->undefined_value(); |
| + break; |
| } |
| - UNREACHABLE(); // keep the compiler happy |
| - return heap->undefined_value(); |
| + ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
| + return value->IsTheHole() |
| + ? Handle<Object>::cast(isolate->factory()->undefined_value()) : value; |
| } |
| @@ -10847,29 +10829,23 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { |
| result_callback_obj = Handle<Object>(result.GetCallbackObject(), |
| isolate); |
| } |
| - Smi* property_details = result.GetPropertyDetails().AsSmi(); |
| - // DebugLookupResultValue can cause GC so details from LookupResult needs |
| - // to be copied to handles before this. |
| - bool caught_exception = false; |
| - Object* raw_value; |
| - { MaybeObject* maybe_raw_value = |
| - DebugLookupResultValue(isolate->heap(), *obj, *name, |
| - &result, &caught_exception); |
| - if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value; |
| - } |
| - Handle<Object> value(raw_value, isolate); |
| + |
| + Handle<Object> value; |
| + bool has_caught = |
| + !DebugLookupResultValue(isolate, obj, name, &result).ToHandle(&value); |
| + if (has_caught) value = handle(isolate->pending_exception(), isolate); |
| // If the callback object is a fixed array then it contains JavaScript |
| // getter and/or setter. |
| - bool hasJavaScriptAccessors = result.IsPropertyCallbacks() && |
| - result_callback_obj->IsAccessorPair(); |
| + bool has_js_accessors = result.IsPropertyCallbacks() && |
| + result_callback_obj->IsAccessorPair(); |
| Handle<FixedArray> details = |
| - isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); |
| + isolate->factory()->NewFixedArray(has_js_accessors ? 5 : 2); |
| details->set(0, *value); |
| - details->set(1, property_details); |
| - if (hasJavaScriptAccessors) { |
| + details->set(1, result.GetPropertyDetails().AsSmi()); |
| + if (has_js_accessors) { |
| AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); |
| - details->set(2, isolate->heap()->ToBoolean(caught_exception)); |
| + details->set(2, isolate->heap()->ToBoolean(has_caught)); |
| details->set(3, accessors->GetComponent(ACCESSOR_GETTER)); |
| details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); |
| } |
| @@ -10895,10 +10871,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { |
| LookupResult result(isolate); |
| obj->Lookup(*name, &result); |
| - if (result.IsFound()) { |
| - return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); |
| - } |
| - return isolate->heap()->undefined_value(); |
| + Handle<Object> value; |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| + isolate, value, DebugLookupResultValue(isolate, obj, name, &result)); |
| + return *value; |
| } |