Commit 203e4150 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handlify DebugLookupResultValue.

R=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20729 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c1435b08
...@@ -806,8 +806,8 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object, ...@@ -806,8 +806,8 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
Handle<Object> value; Handle<Object> value;
switch (result->type()) { switch (result->type()) {
case NORMAL: { case NORMAL: {
DisallowHeapAllocation no_gc; value = JSObject::GetNormalizedProperty(
value = handle(result->holder()->GetNormalizedProperty(result), isolate); handle(result->holder(), isolate), result);
break; break;
} }
case FIELD: case FIELD:
......
...@@ -10718,63 +10718,49 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { ...@@ -10718,63 +10718,49 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) {
} }
static MaybeObject* DebugLookupResultValue(Heap* heap, static Handle<Object> DebugLookupResultValue(Isolate* isolate,
Object* receiver, Handle<Object> receiver,
Name* name, Handle<Name> name,
LookupResult* result, LookupResult* result,
bool* caught_exception) { bool* has_caught = NULL) {
Object* value; Handle<Object> value = isolate->factory()->undefined_value();
if (result->IsTransition()) return heap->undefined_value(); if (!result->IsFound()) return value;
switch (result->type()) { switch (result->type()) {
case NORMAL: case NORMAL:
value = result->holder()->GetNormalizedProperty(result); value = JSObject::GetNormalizedProperty(
if (value->IsTheHole()) { handle(result->holder(), isolate), result);
return heap->undefined_value(); break;
} case FIELD:
return value; value = JSObject::FastPropertyAt(handle(result->holder(), isolate),
case FIELD: { result->representation(),
Object* value; result->GetFieldIndex().field_index());
MaybeObject* maybe_value = break;
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 CONSTANT: case CONSTANT:
return result->GetConstant(); return handle(result->GetConstant(), isolate);
case CALLBACKS: { case CALLBACKS: {
Object* structure = result->GetCallbackObject(); Handle<Object> structure(result->GetCallbackObject(), isolate);
if (structure->IsForeign() || structure->IsAccessorInfo()) { if (structure->IsForeign() || structure->IsAccessorInfo()) {
Isolate* isolate = heap->isolate(); MaybeHandle<Object> obj = JSObject::GetPropertyWithCallback(
HandleScope scope(isolate); handle(result->holder(), isolate), receiver, structure, name);
MaybeHandle<Object> maybe_value = JSObject::GetPropertyWithCallback( if (!obj.ToHandle(&value)) {
handle(result->holder(), isolate), value = handle(isolate->pending_exception(), isolate);
handle(receiver, isolate), isolate->clear_pending_exception();
handle(structure, isolate), if (has_caught != NULL) *has_caught = true;
handle(name, isolate)); return value;
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:
return heap->undefined_value(); break;
case HANDLER: case HANDLER:
case NONEXISTENT: case NONEXISTENT:
UNREACHABLE(); UNREACHABLE();
return heap->undefined_value(); break;
} }
UNREACHABLE(); // keep the compiler happy ASSERT(!value->IsTheHole() || result->IsReadOnly());
return heap->undefined_value(); return value->IsTheHole()
? Handle<Object>::cast(isolate->factory()->undefined_value()) : value;
} }
...@@ -10848,29 +10834,23 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { ...@@ -10848,29 +10834,23 @@ 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
// to be copied to handles before this. bool has_caught;
bool caught_exception = false; Handle<Object> value = DebugLookupResultValue(
Object* raw_value; isolate, obj, name, &result, &has_caught);
{ 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 hasJavaScriptAccessors = result.IsPropertyCallbacks() && bool has_js_accessors = result.IsPropertyCallbacks() &&
result_callback_obj->IsAccessorPair(); result_callback_obj->IsAccessorPair();
Handle<FixedArray> details = Handle<FixedArray> details =
isolate->factory()->NewFixedArray(hasJavaScriptAccessors ? 5 : 2); isolate->factory()->NewFixedArray(has_js_accessors ? 5 : 2);
details->set(0, *value); details->set(0, *value);
details->set(1, property_details); details->set(1, result.GetPropertyDetails().AsSmi());
if (hasJavaScriptAccessors) { if (has_js_accessors) {
AccessorPair* accessors = AccessorPair::cast(*result_callback_obj); 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(3, accessors->GetComponent(ACCESSOR_GETTER));
details->set(4, accessors->GetComponent(ACCESSOR_SETTER)); details->set(4, accessors->GetComponent(ACCESSOR_SETTER));
} }
...@@ -10896,10 +10876,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { ...@@ -10896,10 +10876,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) {
LookupResult result(isolate); LookupResult result(isolate);
obj->Lookup(*name, &result); obj->Lookup(*name, &result);
if (result.IsFound()) { return *DebugLookupResultValue(isolate, obj, name, &result);
return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL);
}
return isolate->heap()->undefined_value();
} }
......
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