Revert "Handlify DebugLookupResultValue."

This reverts r20729.

TBR=jarin@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20732 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-04-14 14:34:37 +00:00
parent b173d2cd15
commit d42146c8b8
2 changed files with 71 additions and 48 deletions

View File

@ -811,8 +811,8 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
Handle<Object> value; Handle<Object> value;
switch (result->type()) { switch (result->type()) {
case NORMAL: { case NORMAL: {
value = JSObject::GetNormalizedProperty( DisallowHeapAllocation no_gc;
handle(result->holder(), isolate), result); value = handle(result->holder()->GetNormalizedProperty(result), isolate);
break; break;
} }
case FIELD: case FIELD:

View File

@ -10714,49 +10714,63 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) {
} }
static Handle<Object> DebugLookupResultValue(Isolate* isolate, static MaybeObject* DebugLookupResultValue(Heap* heap,
Handle<Object> receiver, Object* receiver,
Handle<Name> name, Name* name,
LookupResult* result, LookupResult* result,
bool* has_caught = NULL) { bool* caught_exception) {
Handle<Object> value = isolate->factory()->undefined_value(); Object* value;
if (!result->IsFound()) return value; if (result->IsTransition()) return heap->undefined_value();
switch (result->type()) { switch (result->type()) {
case NORMAL: case NORMAL:
value = JSObject::GetNormalizedProperty( value = result->holder()->GetNormalizedProperty(result);
handle(result->holder(), isolate), result); if (value->IsTheHole()) {
break; return heap->undefined_value();
case FIELD: }
value = JSObject::FastPropertyAt(handle(result->holder(), isolate), return value;
case FIELD: {
Object* value;
MaybeObject* maybe_value =
JSObject::cast(result->holder())->FastPropertyAt(
result->representation(), result->representation(),
result->GetFieldIndex().field_index()); result->GetFieldIndex().field_index());
break; if (!maybe_value->To(&value)) return maybe_value;
case CONSTANT: if (value->IsTheHole()) {
return handle(result->GetConstant(), isolate); return heap->undefined_value();
case CALLBACKS: { }
Handle<Object> structure(result->GetCallbackObject(), isolate);
if (structure->IsForeign() || structure->IsAccessorInfo()) {
MaybeHandle<Object> obj = JSObject::GetPropertyWithCallback(
handle(result->holder(), isolate), receiver, structure, name);
if (!obj.ToHandle(&value)) {
value = handle(isolate->pending_exception(), isolate);
isolate->clear_pending_exception();
if (has_caught != NULL) *has_caught = true;
return value; return value;
} }
case CONSTANT:
return result->GetConstant();
case CALLBACKS: {
Object* structure = result->GetCallbackObject();
if (structure->IsForeign() || structure->IsAccessorInfo()) {
Isolate* isolate = heap->isolate();
HandleScope scope(isolate);
MaybeHandle<Object> maybe_value = 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();
} }
break;
} }
case INTERCEPTOR: case INTERCEPTOR:
break; return heap->undefined_value();
case HANDLER: case HANDLER:
case NONEXISTENT: case NONEXISTENT:
UNREACHABLE(); UNREACHABLE();
break; return heap->undefined_value();
} }
ASSERT(!value->IsTheHole() || result->IsReadOnly()); UNREACHABLE(); // keep the compiler happy
return value->IsTheHole() return heap->undefined_value();
? Handle<Object>::cast(isolate->factory()->undefined_value()) : value;
} }
@ -10830,23 +10844,29 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) {
result_callback_obj = Handle<Object>(result.GetCallbackObject(), result_callback_obj = Handle<Object>(result.GetCallbackObject(),
isolate); isolate);
} }
Smi* property_details = result.GetPropertyDetails().AsSmi();
// DebugLookupResultValue can cause GC so details from LookupResult needs
bool has_caught; // to be copied to handles before this.
Handle<Object> value = DebugLookupResultValue( bool caught_exception = false;
isolate, obj, name, &result, &has_caught); 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);
// If the callback object is a fixed array then it contains JavaScript // If the callback object is a fixed array then it contains JavaScript
// getter and/or setter. // getter and/or setter.
bool has_js_accessors = result.IsPropertyCallbacks() && bool hasJavaScriptAccessors = result.IsPropertyCallbacks() &&
result_callback_obj->IsAccessorPair(); result_callback_obj->IsAccessorPair();
Handle<FixedArray> details = Handle<FixedArray> details =
isolate->factory()->NewFixedArray(has_js_accessors ? 5 : 2); isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2);
details->set(0, *value); details->set(0, *value);
details->set(1, result.GetPropertyDetails().AsSmi()); details->set(1, property_details);
if (has_js_accessors) { if (hasJavaScriptAccessors) {
AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); AccessorPair* accessors = AccessorPair::cast(*result_callback_obj);
details->set(2, isolate->heap()->ToBoolean(has_caught)); details->set(2, isolate->heap()->ToBoolean(caught_exception));
details->set(3, accessors->GetComponent(ACCESSOR_GETTER)); details->set(3, accessors->GetComponent(ACCESSOR_GETTER));
details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); details->set(4, accessors->GetComponent(ACCESSOR_SETTER));
} }
@ -10872,7 +10892,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) {
LookupResult result(isolate); LookupResult result(isolate);
obj->Lookup(*name, &result); obj->Lookup(*name, &result);
return *DebugLookupResultValue(isolate, obj, name, &result); if (result.IsFound()) {
return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
}
return isolate->heap()->undefined_value();
} }