Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index 3f810867388e4915c9c95d6c1bed6aaad880dec6..a823da13d8297fb2321c50085a7a54fc30f6462f 100644 |
| --- a/src/builtins.cc |
| +++ b/src/builtins.cc |
| @@ -1109,16 +1109,16 @@ BUILTIN(StrictModePoisonPill) { |
| // Searches the hidden prototype chain of the given object for the first |
| // object that is an instance of the given type. If no such object can |
| // be found then Heap::null_value() is returned. |
| -static inline Object* FindHidden(Heap* heap, |
| - Object* object, |
| - FunctionTemplateInfo* type) { |
| - if (type->IsTemplateFor(object)) return object; |
| - Object* proto = object->GetPrototype(heap->isolate()); |
| +static inline Handle<Object> FindHidden(Isolate* isolate, |
| + Handle<Object> object, |
| + Handle<FunctionTemplateInfo> type) { |
|
Yang
2014/04/15 13:10:48
It seems like we don't need to handlify this and i
|
| + if (type->IsTemplateFor(*object)) return object; |
| + Handle<Object> proto = Object::GetPrototype(isolate, object); |
| if (proto->IsJSObject() && |
| - JSObject::cast(proto)->map()->is_hidden_prototype()) { |
| - return FindHidden(heap, proto, type); |
| + JSObject::cast(*proto)->map()->is_hidden_prototype()) { |
| + return FindHidden(isolate, proto, type); |
| } |
| - return heap->null_value(); |
| + return Handle<Object>(); |
| } |
| @@ -1132,6 +1132,9 @@ static inline Object* TypeCheck(Heap* heap, |
| int argc, |
| Object** argv, |
| FunctionTemplateInfo* info) { |
| + Isolate* isolate = heap->isolate(); |
| + HandleScope scope(isolate); |
| + DisallowHeapAllocation no_alloc; |
| Object* recv = argv[0]; |
| // API calls are only supported with JSObject receivers. |
| if (!recv->IsJSObject()) return heap->null_value(); |
| @@ -1142,8 +1145,13 @@ static inline Object* TypeCheck(Heap* heap, |
| Object* recv_type = sig->receiver(); |
| Object* holder = recv; |
| if (!recv_type->IsUndefined()) { |
| - holder = FindHidden(heap, holder, FunctionTemplateInfo::cast(recv_type)); |
| - if (holder == heap->null_value()) return heap->null_value(); |
| + Handle<Object> hidden = |
| + FindHidden( |
| + isolate, |
| + handle(holder, isolate), |
| + handle(FunctionTemplateInfo::cast(recv_type))); |
| + if (hidden.is_null()) return heap->null_value(); |
| + holder = *hidden; |
| } |
| Object* args_obj = sig->args(); |
| // If there is no argument signature we're done |
| @@ -1155,10 +1163,14 @@ static inline Object* TypeCheck(Heap* heap, |
| Object* argtype = args->get(i); |
| if (argtype->IsUndefined()) continue; |
| Object** arg = &argv[-1 - i]; |
| - Object* current = *arg; |
| - current = FindHidden(heap, current, FunctionTemplateInfo::cast(argtype)); |
| - if (current == heap->null_value()) current = heap->undefined_value(); |
| - *arg = current; |
| + Handle<Object> current(*arg, isolate); |
| + current = FindHidden( |
| + isolate, current, handle(FunctionTemplateInfo::cast(argtype))); |
| + if (!current.is_null()) { |
| + *arg = *current; |
| + } else { |
| + *arg = heap->undefined_value(); |
| + } |
| } |
| return holder; |
| } |