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/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/ast/prettyprinter.h" | 8 #include "src/ast/prettyprinter.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 DCHECK(args.length() == 4); | 387 DCHECK(args.length() == 4); |
388 CONVERT_INT32_ARG_CHECKED(template_index, 0); | 388 CONVERT_INT32_ARG_CHECKED(template_index, 0); |
389 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 1); | 389 CONVERT_ARG_HANDLE_CHECKED(String, arg0, 1); |
390 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); | 390 CONVERT_ARG_HANDLE_CHECKED(String, arg1, 2); |
391 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); | 391 CONVERT_ARG_HANDLE_CHECKED(String, arg2, 3); |
392 isolate->native_context()->IncrementErrorsThrown(); | 392 isolate->native_context()->IncrementErrorsThrown(); |
393 RETURN_RESULT_OR_FAILURE(isolate, MessageTemplate::FormatMessage( | 393 RETURN_RESULT_OR_FAILURE(isolate, MessageTemplate::FormatMessage( |
394 template_index, arg0, arg1, arg2)); | 394 template_index, arg0, arg1, arg2)); |
395 } | 395 } |
396 | 396 |
397 #define CALLSITE_GET(NAME, RETURN) \ | |
398 RUNTIME_FUNCTION(Runtime_CallSite##NAME##RT) { \ | |
399 HandleScope scope(isolate); \ | |
400 DCHECK(args.length() == 1); \ | |
401 CONVERT_ARG_HANDLE_CHECKED(JSObject, call_site_obj, 0); \ | |
402 Handle<String> result; \ | |
403 CallSite call_site(isolate, call_site_obj); \ | |
404 CHECK(call_site.IsJavaScript() || call_site.IsWasm()); \ | |
405 return RETURN(call_site.NAME(), isolate); \ | |
406 } | |
407 | |
408 static inline Object* ReturnDereferencedHandle(Handle<Object> obj, | |
409 Isolate* isolate) { | |
410 return *obj; | |
411 } | |
412 | |
413 | |
414 static inline Object* ReturnPositiveNumberOrNull(int value, Isolate* isolate) { | |
415 if (value >= 0) return *isolate->factory()->NewNumberFromInt(value); | |
416 return isolate->heap()->null_value(); | |
417 } | |
418 | |
419 | |
420 static inline Object* ReturnBoolean(bool value, Isolate* isolate) { | |
421 return isolate->heap()->ToBoolean(value); | |
422 } | |
423 | |
424 | |
425 CALLSITE_GET(GetFileName, ReturnDereferencedHandle) | |
426 CALLSITE_GET(GetFunctionName, ReturnDereferencedHandle) | |
427 CALLSITE_GET(GetScriptNameOrSourceUrl, ReturnDereferencedHandle) | |
428 CALLSITE_GET(GetMethodName, ReturnDereferencedHandle) | |
429 CALLSITE_GET(GetLineNumber, ReturnPositiveNumberOrNull) | |
430 CALLSITE_GET(GetColumnNumber, ReturnPositiveNumberOrNull) | |
431 CALLSITE_GET(IsNative, ReturnBoolean) | |
432 CALLSITE_GET(IsToplevel, ReturnBoolean) | |
433 CALLSITE_GET(IsEval, ReturnBoolean) | |
434 CALLSITE_GET(IsConstructor, ReturnBoolean) | |
435 | |
436 #undef CALLSITE_GET | |
437 | |
438 | 397 |
439 RUNTIME_FUNCTION(Runtime_IS_VAR) { | 398 RUNTIME_FUNCTION(Runtime_IS_VAR) { |
440 UNREACHABLE(); // implemented as macro in the parser | 399 UNREACHABLE(); // implemented as macro in the parser |
441 return NULL; | 400 return NULL; |
442 } | 401 } |
443 | 402 |
444 | 403 |
445 namespace { | 404 namespace { |
446 | 405 |
447 bool ComputeLocation(Isolate* isolate, MessageLocation* target) { | 406 bool ComputeLocation(Isolate* isolate, MessageLocation* target) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 HandleScope scope(isolate); | 578 HandleScope scope(isolate); |
620 DCHECK_EQ(1, args.length()); | 579 DCHECK_EQ(1, args.length()); |
621 CONVERT_ARG_CHECKED(Object, object, 0); | 580 CONVERT_ARG_CHECKED(Object, object, 0); |
622 bool is_wasm_object = | 581 bool is_wasm_object = |
623 object->IsJSObject() && wasm::IsWasmObject(JSObject::cast(object)); | 582 object->IsJSObject() && wasm::IsWasmObject(JSObject::cast(object)); |
624 return *isolate->factory()->ToBoolean(is_wasm_object); | 583 return *isolate->factory()->ToBoolean(is_wasm_object); |
625 } | 584 } |
626 | 585 |
627 } // namespace internal | 586 } // namespace internal |
628 } // namespace v8 | 587 } // namespace v8 |
OLD | NEW |