Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2103983003: Revert "[wasm] Complete separation of compilation and instantiation" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 #ifndef WASM_RUN_UTILS_H 5 #ifndef WASM_RUN_UTILS_H
6 #define WASM_RUN_UTILS_H 6 #define WASM_RUN_UTILS_H
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); 179 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index));
180 } 180 }
181 DCHECK_LT(index, kMaxFunctions); // limited for testing. 181 DCHECK_LT(index, kMaxFunctions); // limited for testing.
182 return index; 182 return index;
183 } 183 }
184 184
185 uint32_t AddJsFunction(FunctionSig* sig, const char* source) { 185 uint32_t AddJsFunction(FunctionSig* sig, const char* source) {
186 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle( 186 Handle<JSFunction> jsfunc = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
187 *v8::Local<v8::Function>::Cast(CompileRun(source)))); 187 *v8::Local<v8::Function>::Cast(CompileRun(source))));
188 uint32_t index = AddFunction(sig, Handle<Code>::null()); 188 uint32_t index = AddFunction(sig, Handle<Code>::null());
189 Handle<Code> code = 189 WasmName module_name = ArrayVector("test");
190 CompileWasmToJSWrapper(isolate_, jsfunc, sig, index, 190 WasmName function_name;
191 Handle<String>::null(), Handle<String>::null()); 191 Handle<Code> code = CompileWasmToJSWrapper(isolate_, jsfunc, sig,
192 module_name, function_name);
192 instance->function_code[index] = code; 193 instance->function_code[index] = code;
193 return index; 194 return index;
194 } 195 }
195 196
196 Handle<JSFunction> WrapCode(uint32_t index) { 197 Handle<JSFunction> WrapCode(uint32_t index) {
197 // Wrap the code so it can be called as a JS function. 198 // Wrap the code so it can be called as a JS function.
198 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main"); 199 Handle<String> name = isolate_->factory()->NewStringFromStaticChars("main");
199 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_); 200 Handle<JSObject> module_object = Handle<JSObject>(0, isolate_);
200 Handle<Code> code = instance->function_code[index]; 201 Handle<Code> code = instance->function_code[index];
201 WasmJs::InstallWasmFunctionMap(isolate_, isolate_->native_context()); 202 WasmJs::InstallWasmFunctionMap(isolate_, isolate_->native_context());
202 Handle<JSFunction> ret = 203 return compiler::CompileJSToWasmWrapper(isolate_, this, name, code,
203 compiler::CompileJSToWasmWrapper(isolate_, this, name, code, index); 204 module_object, index);
204 ret->SetInternalField(0, *module_object);
205 return ret;
206 } 205 }
207 206
208 void SetFunctionCode(uint32_t index, Handle<Code> code) { 207 void SetFunctionCode(uint32_t index, Handle<Code> code) {
209 instance->function_code[index] = code; 208 instance->function_code[index] = code;
210 } 209 }
211 210
212 void AddIndirectFunctionTable(int* functions, int table_size) { 211 void AddIndirectFunctionTable(int* functions, int table_size) {
213 Handle<FixedArray> fixed = 212 Handle<FixedArray> fixed =
214 isolate_->factory()->NewFixedArray(2 * table_size); 213 isolate_->factory()->NewFixedArray(2 * table_size);
215 instance->function_table = fixed; 214 instance->function_table = fixed;
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // interpreter. 754 // interpreter.
756 #define WASM_EXEC_TEST(name) \ 755 #define WASM_EXEC_TEST(name) \
757 void RunWasm_##name(WasmExecutionMode execution_mode); \ 756 void RunWasm_##name(WasmExecutionMode execution_mode); \
758 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 757 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
759 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 758 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
760 void RunWasm_##name(WasmExecutionMode execution_mode) 759 void RunWasm_##name(WasmExecutionMode execution_mode)
761 760
762 } // namespace 761 } // namespace
763 762
764 #endif 763 #endif
OLDNEW
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698