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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return isolate->ReThrow(args[0]); | 93 return isolate->ReThrow(args[0]); |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 RUNTIME_FUNCTION(Runtime_ThrowStackOverflow) { | 97 RUNTIME_FUNCTION(Runtime_ThrowStackOverflow) { |
98 SealHandleScope shs(isolate); | 98 SealHandleScope shs(isolate); |
99 DCHECK_LE(0, args.length()); | 99 DCHECK_LE(0, args.length()); |
100 return isolate->StackOverflow(); | 100 return isolate->StackOverflow(); |
101 } | 101 } |
102 | 102 |
| 103 RUNTIME_FUNCTION(Runtime_ThrowTypeError) { |
| 104 HandleScope scope(isolate); |
| 105 DCHECK_LE(1, args.length()); |
| 106 CONVERT_SMI_ARG_CHECKED(message_id_smi, 0); |
| 107 |
| 108 Handle<Object> undefined = isolate->factory()->undefined_value(); |
| 109 Handle<Object> arg0 = (args.length() > 1) ? args.at<Object>(1) : undefined; |
| 110 Handle<Object> arg1 = (args.length() > 2) ? args.at<Object>(2) : undefined; |
| 111 Handle<Object> arg2 = (args.length() > 3) ? args.at<Object>(3) : undefined; |
| 112 |
| 113 MessageTemplate::Template message_id = |
| 114 static_cast<MessageTemplate::Template>(message_id_smi); |
| 115 |
| 116 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 117 NewTypeError(message_id, arg0, arg1, arg2)); |
| 118 } |
| 119 |
103 RUNTIME_FUNCTION(Runtime_ThrowWasmError) { | 120 RUNTIME_FUNCTION(Runtime_ThrowWasmError) { |
104 HandleScope scope(isolate); | 121 HandleScope scope(isolate); |
105 DCHECK_EQ(2, args.length()); | 122 DCHECK_EQ(2, args.length()); |
106 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 123 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
107 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); | 124 CONVERT_SMI_ARG_CHECKED(byte_offset, 1); |
108 Handle<Object> error_obj = isolate->factory()->NewError( | 125 Handle<Object> error_obj = isolate->factory()->NewError( |
109 static_cast<MessageTemplate::Template>(message_id)); | 126 static_cast<MessageTemplate::Template>(message_id)); |
110 | 127 |
111 // For wasm traps, the byte offset (a.k.a source position) can not be | 128 // For wasm traps, the byte offset (a.k.a source position) can not be |
112 // determined from relocation info, since the explicit checks for traps | 129 // determined from relocation info, since the explicit checks for traps |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 621 |
605 RUNTIME_FUNCTION(Runtime_Typeof) { | 622 RUNTIME_FUNCTION(Runtime_Typeof) { |
606 HandleScope scope(isolate); | 623 HandleScope scope(isolate); |
607 DCHECK_EQ(1, args.length()); | 624 DCHECK_EQ(1, args.length()); |
608 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 625 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
609 return *Object::TypeOf(isolate, object); | 626 return *Object::TypeOf(isolate, object); |
610 } | 627 } |
611 | 628 |
612 } // namespace internal | 629 } // namespace internal |
613 } // namespace v8 | 630 } // namespace v8 |
OLD | NEW |