OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 object = proto; | 406 object = proto; |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 Object* CallICBase::TryCallAsFunction(Object* object) { | 411 Object* CallICBase::TryCallAsFunction(Object* object) { |
412 HandleScope scope(isolate()); | 412 HandleScope scope(isolate()); |
413 Handle<Object> target(object, isolate()); | 413 Handle<Object> target(object, isolate()); |
414 Handle<Object> delegate = Execution::GetFunctionDelegate(target); | 414 Handle<Object> delegate = Execution::GetFunctionDelegate(target); |
415 | 415 |
416 if (delegate->IsJSFunction()) { | 416 if (delegate->IsJSFunction() && !object->IsJSFunctionProxy()) { |
417 // Patch the receiver and use the delegate as the function to | 417 // Patch the receiver and use the delegate as the function to |
418 // invoke. This is used for invoking objects as if they were | 418 // invoke. This is used for invoking objects as if they were |
419 // functions. | 419 // functions. |
420 const int argc = this->target()->arguments_count(); | 420 const int argc = this->target()->arguments_count(); |
421 StackFrameLocator locator; | 421 StackFrameLocator locator; |
422 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 422 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
423 int index = frame->ComputeExpressionsCount() - (argc + 1); | 423 int index = frame->ComputeExpressionsCount() - (argc + 1); |
424 frame->SetExpression(index, *target); | 424 frame->SetExpression(index, *target); |
425 } | 425 } |
426 | 426 |
427 return *delegate; | 427 return *delegate; |
428 } | 428 } |
429 | 429 |
430 | 430 |
431 void CallICBase::ReceiverToObjectIfRequired(Handle<Object> callee, | 431 void CallICBase::ReceiverToObjectIfRequired(Handle<Object> callee, |
432 Handle<Object> object) { | 432 Handle<Object> object) { |
433 while (callee->IsJSFunctionProxy()) | |
434 callee = Handle<Object>(JSFunctionProxy::cast(*callee)->call_trap()); | |
Kevin Millikin (Chromium)
2011/10/13 14:36:40
V8 style is braces around this body (unless it cou
| |
435 | |
433 if (callee->IsJSFunction()) { | 436 if (callee->IsJSFunction()) { |
434 Handle<JSFunction> function = Handle<JSFunction>::cast(callee); | 437 Handle<JSFunction> function = Handle<JSFunction>::cast(callee); |
435 if (function->shared()->strict_mode() || function->IsBuiltin()) { | 438 if (function->shared()->strict_mode() || function->IsBuiltin()) { |
436 // Do not wrap receiver for strict mode functions or for builtins. | 439 // Do not wrap receiver for strict mode functions or for builtins. |
437 return; | 440 return; |
438 } | 441 } |
439 } | 442 } |
440 | 443 |
441 // And only wrap string, number or boolean. | 444 // And only wrap string, number or boolean. |
442 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { | 445 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { |
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2577 #undef ADDR | 2580 #undef ADDR |
2578 }; | 2581 }; |
2579 | 2582 |
2580 | 2583 |
2581 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2584 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2582 return IC_utilities[id]; | 2585 return IC_utilities[id]; |
2583 } | 2586 } |
2584 | 2587 |
2585 | 2588 |
2586 } } // namespace v8::internal | 2589 } } // namespace v8::internal |
OLD | NEW |