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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/frames-inl.h" | 10 #include "src/frames-inl.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 Execution::Call(isolate, target, receiver, argc, argv.start())); | 273 Execution::Call(isolate, target, receiver, argc, argv.start())); |
274 return *result; | 274 return *result; |
275 } | 275 } |
276 | 276 |
277 | 277 |
278 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. | 278 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. |
279 RUNTIME_FUNCTION(Runtime_ConvertReceiver) { | 279 RUNTIME_FUNCTION(Runtime_ConvertReceiver) { |
280 HandleScope scope(isolate); | 280 HandleScope scope(isolate); |
281 DCHECK(args.length() == 1); | 281 DCHECK(args.length() == 1); |
282 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 282 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
283 return *Object::ConvertReceiver(isolate, receiver).ToHandleChecked(); | 283 if (receiver->IsNull() || receiver->IsUndefined()) { |
| 284 return isolate->global_proxy(); |
| 285 } |
| 286 return *Object::ToObject(isolate, receiver).ToHandleChecked(); |
284 } | 287 } |
285 | 288 |
286 | 289 |
287 RUNTIME_FUNCTION(Runtime_IsFunction) { | 290 RUNTIME_FUNCTION(Runtime_IsFunction) { |
288 SealHandleScope shs(isolate); | 291 SealHandleScope shs(isolate); |
289 DCHECK_EQ(1, args.length()); | 292 DCHECK_EQ(1, args.length()); |
290 CONVERT_ARG_CHECKED(Object, object, 0); | 293 CONVERT_ARG_CHECKED(Object, object, 0); |
291 return isolate->heap()->ToBoolean(object->IsFunction()); | 294 return isolate->heap()->ToBoolean(object->IsFunction()); |
292 } | 295 } |
293 | 296 |
294 | 297 |
295 RUNTIME_FUNCTION(Runtime_FunctionToString) { | 298 RUNTIME_FUNCTION(Runtime_FunctionToString) { |
296 HandleScope scope(isolate); | 299 HandleScope scope(isolate); |
297 DCHECK_EQ(1, args.length()); | 300 DCHECK_EQ(1, args.length()); |
298 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); | 301 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); |
299 return function->IsJSBoundFunction() | 302 return function->IsJSBoundFunction() |
300 ? *JSBoundFunction::ToString( | 303 ? *JSBoundFunction::ToString( |
301 Handle<JSBoundFunction>::cast(function)) | 304 Handle<JSBoundFunction>::cast(function)) |
302 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); | 305 : *JSFunction::ToString(Handle<JSFunction>::cast(function)); |
303 } | 306 } |
304 | 307 |
305 } // namespace internal | 308 } // namespace internal |
306 } // namespace v8 | 309 } // namespace v8 |
OLD | NEW |