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/compiler/wasm-compiler.h" | |
10 #include "src/conversions.h" | 11 #include "src/conversions.h" |
11 #include "src/debug/debug.h" | 12 #include "src/debug/debug.h" |
12 #include "src/frames-inl.h" | 13 #include "src/frames-inl.h" |
13 #include "src/isolate-inl.h" | 14 #include "src/isolate-inl.h" |
14 #include "src/messages.h" | 15 #include "src/messages.h" |
15 #include "src/parsing/parser.h" | 16 #include "src/parsing/parser.h" |
16 #include "src/wasm/wasm-module.h" | 17 #include "src/wasm/wasm-module.h" |
17 | 18 |
18 namespace v8 { | 19 namespace v8 { |
19 namespace internal { | 20 namespace internal { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 Maybe<bool> data_set = JSReceiver::SetDataProperty( | 146 Maybe<bool> data_set = JSReceiver::SetDataProperty( |
146 &it, handle(Smi::FromInt(byte_offset + 1), isolate)); | 147 &it, handle(Smi::FromInt(byte_offset + 1), isolate)); |
147 DCHECK(data_set.IsJust() && data_set.FromJust() == true); | 148 DCHECK(data_set.IsJust() && data_set.FromJust() == true); |
148 USE(data_set); | 149 USE(data_set); |
149 } | 150 } |
150 } | 151 } |
151 | 152 |
152 return isolate->Throw(*error_obj); | 153 return isolate->Throw(*error_obj); |
153 } | 154 } |
154 | 155 |
156 RUNTIME_FUNCTION(Runtime_JITSingleFunction) { | |
157 HandleScope scope(isolate); | |
158 DCHECK_LE(7, args.length()); | |
Mircea Trofin
2016/07/12 02:49:12
same comment as before about numbers - if possible
ritesht
2016/07/13 23:58:45
Done.
| |
159 CONVERT_SMI_ARG_CHECKED(base, 0); | |
160 CONVERT_SMI_ARG_CHECKED(length, 1); | |
161 CONVERT_SMI_ARG_CHECKED(index, 2); | |
162 CONVERT_INTPTR_ARG_CHECKED(start, 3); | |
163 CONVERT_ARG_HANDLE_CHECKED(FixedArray, function_table, 4); | |
164 CONVERT_SMI_ARG_CHECKED(sig_index, 5); | |
165 CONVERT_UINT32_ARG_CHECKED(return_count, 6); | |
166 | |
167 wasm::WasmModule module(reinterpret_cast<byte*>(start)); | |
168 wasm::ErrorThrower thrower(isolate, "JITSingleFunction"); | |
169 wasm::ModuleEnv module_env; | |
170 module_env.module = &module; | |
171 module_env.instance = nullptr; | |
172 module_env.origin = wasm::kWasmOrigin; | |
173 | |
174 uint32_t signature_size = args.length() - 7; | |
175 wasm::LocalType* sig_types = new wasm::LocalType[signature_size]; | |
176 | |
177 for (uint32_t i = 0; i < signature_size; ++i) { | |
178 CONVERT_SMI_ARG_CHECKED(sig_type, i + 7); | |
179 sig_types[i] = static_cast<wasm::LocalType>(sig_type); | |
180 } | |
181 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types); | |
182 | |
183 wasm::WasmFunction func; | |
184 func.sig = &sig; | |
185 func.func_index = index; | |
186 func.sig_index = sig_index; | |
187 func.name_offset = 0; | |
188 func.name_length = 0; | |
189 func.code_start_offset = base; | |
190 func.code_end_offset = base + length; | |
191 | |
192 Handle<Code> code = compiler::WasmCompilationUnit::CompileWasmFunction( | |
193 &thrower, isolate, &module_env, &func); | |
194 | |
195 delete[] sig_types; | |
196 if (thrower.error()) { | |
197 return isolate->heap()->undefined_value(); | |
198 } | |
199 | |
200 function_table->set(index, Smi::FromInt(sig_index)); | |
201 function_table->set(index + function_table->length() / 2, *code); | |
Mircea Trofin
2016/07/12 02:49:13
do you want to check that index < function_table->
ritesht
2016/07/13 23:58:45
Done.
| |
202 | |
203 return isolate->heap()->undefined_value(); | |
204 } | |
205 | |
155 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { | 206 RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { |
156 SealHandleScope shs(isolate); | 207 SealHandleScope shs(isolate); |
157 DCHECK(args.length() == 0); | 208 DCHECK(args.length() == 0); |
158 return isolate->UnwindAndFindHandler(); | 209 return isolate->UnwindAndFindHandler(); |
159 } | 210 } |
160 | 211 |
161 | 212 |
162 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { | 213 RUNTIME_FUNCTION(Runtime_PromoteScheduledException) { |
163 SealHandleScope shs(isolate); | 214 SealHandleScope shs(isolate); |
164 DCHECK(args.length() == 0); | 215 DCHECK(args.length() == 0); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
628 HandleScope scope(isolate); | 679 HandleScope scope(isolate); |
629 DCHECK_EQ(1, args.length()); | 680 DCHECK_EQ(1, args.length()); |
630 CONVERT_ARG_CHECKED(Object, object, 0); | 681 CONVERT_ARG_CHECKED(Object, object, 0); |
631 bool is_wasm_object = | 682 bool is_wasm_object = |
632 object->IsJSObject() && wasm::IsWasmObject(JSObject::cast(object)); | 683 object->IsJSObject() && wasm::IsWasmObject(JSObject::cast(object)); |
633 return *isolate->factory()->ToBoolean(is_wasm_object); | 684 return *isolate->factory()->ToBoolean(is_wasm_object); |
634 } | 685 } |
635 | 686 |
636 } // namespace internal | 687 } // namespace internal |
637 } // namespace v8 | 688 } // namespace v8 |
OLD | NEW |