| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 isolate, delegate, Execution::TryGetFunctionDelegate( | 26 isolate, delegate, Execution::TryGetFunctionDelegate( |
| 27 isolate, Handle<JSReceiver>(callable))); | 27 isolate, Handle<JSReceiver>(callable))); |
| 28 callable = JSFunction::cast(*delegate); | 28 callable = JSFunction::cast(*delegate); |
| 29 } | 29 } |
| 30 JSFunction* function = JSFunction::cast(callable); | 30 JSFunction* function = JSFunction::cast(callable); |
| 31 SharedFunctionInfo* shared = function->shared(); | 31 SharedFunctionInfo* shared = function->shared(); |
| 32 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode())); | 32 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode())); |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) { | |
| 37 SealHandleScope shs(isolate); | |
| 38 DCHECK(args.length() == 1); | |
| 39 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | |
| 40 | |
| 41 if (!callable->IsJSFunction()) { | |
| 42 HandleScope scope(isolate); | |
| 43 Handle<Object> delegate; | |
| 44 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 45 isolate, delegate, Execution::TryGetFunctionDelegate( | |
| 46 isolate, Handle<JSReceiver>(callable))); | |
| 47 callable = JSFunction::cast(*delegate); | |
| 48 } | |
| 49 JSFunction* function = JSFunction::cast(callable); | |
| 50 | |
| 51 SharedFunctionInfo* shared = function->shared(); | |
| 52 if (shared->native() || is_strict(shared->language_mode())) { | |
| 53 return isolate->heap()->undefined_value(); | |
| 54 } | |
| 55 // Returns undefined for strict or native functions, or | |
| 56 // the associated global receiver for "normal" functions. | |
| 57 | |
| 58 return function->global_proxy(); | |
| 59 } | |
| 60 | |
| 61 | |
| 62 RUNTIME_FUNCTION(Runtime_FunctionGetName) { | 36 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
| 63 SealHandleScope shs(isolate); | 37 SealHandleScope shs(isolate); |
| 64 DCHECK(args.length() == 1); | 38 DCHECK(args.length() == 1); |
| 65 | 39 |
| 66 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 40 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| 67 return f->shared()->name(); | 41 return f->shared()->name(); |
| 68 } | 42 } |
| 69 | 43 |
| 70 | 44 |
| 71 RUNTIME_FUNCTION(Runtime_FunctionSetName) { | 45 RUNTIME_FUNCTION(Runtime_FunctionSetName) { |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 | 599 |
| 626 | 600 |
| 627 RUNTIME_FUNCTION(Runtime_IsFunction) { | 601 RUNTIME_FUNCTION(Runtime_IsFunction) { |
| 628 SealHandleScope shs(isolate); | 602 SealHandleScope shs(isolate); |
| 629 DCHECK(args.length() == 1); | 603 DCHECK(args.length() == 1); |
| 630 CONVERT_ARG_CHECKED(Object, obj, 0); | 604 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 631 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 605 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
| 632 } | 606 } |
| 633 } | 607 } |
| 634 } // namespace v8::internal | 608 } // namespace v8::internal |
| OLD | NEW |