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

Side by Side Diff: src/runtime/runtime-wasm.cc

Issue 2226053002: [wasm] Remove single function JIT support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Drop test Created 4 years, 4 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/runtime/runtime.h ('k') | src/wasm/ast-decoder.h » ('j') | 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 #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/assembler.h" 8 #include "src/assembler.h"
9 #include "src/compiler/wasm-compiler.h" 9 #include "src/compiler/wasm-compiler.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 // Set new buffer to be wasm memory 103 // Set new buffer to be wasm memory
104 module_object->SetInternalField(kWasmMemArrayBuffer, *buffer); 104 module_object->SetInternalField(kWasmMemArrayBuffer, *buffer);
105 105
106 CHECK(wasm::UpdateWasmModuleMemory(module_object, old_mem_start, 106 CHECK(wasm::UpdateWasmModuleMemory(module_object, old_mem_start,
107 new_mem_start, old_size, new_size)); 107 new_mem_start, old_size, new_size));
108 108
109 return *isolate->factory()->NewNumberFromInt(old_size / 109 return *isolate->factory()->NewNumberFromInt(old_size /
110 wasm::WasmModule::kPageSize); 110 wasm::WasmModule::kPageSize);
111 } 111 }
112
113 RUNTIME_FUNCTION(Runtime_JITSingleFunction) {
114 const int fixed_args = 6;
115
116 HandleScope scope(isolate);
117 DCHECK_LE(fixed_args, args.length());
118 CONVERT_SMI_ARG_CHECKED(base, 0);
119 CONVERT_SMI_ARG_CHECKED(length, 1);
120 CONVERT_SMI_ARG_CHECKED(index, 2);
121 CONVERT_ARG_HANDLE_CHECKED(FixedArray, function_table, 3);
122 CONVERT_UINT32_ARG_CHECKED(sig_index, 4);
123 CONVERT_SMI_ARG_CHECKED(return_count, 5);
124
125 Handle<JSObject> module_object;
126
127 {
128 // Get the module JSObject
129 DisallowHeapAllocation no_allocation;
130 const Address entry = Isolate::c_entry_fp(isolate->thread_local_top());
131 Address pc =
132 Memory::Address_at(entry + StandardFrameConstants::kCallerPCOffset);
133 Code* code =
134 isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code;
135 FixedArray* deopt_data = code->deoptimization_data();
136 DCHECK(deopt_data->length() == 2);
137 module_object = Handle<JSObject>::cast(handle(deopt_data->get(0), isolate));
138 CHECK(!module_object->IsNull(isolate));
139 }
140
141 // Get mem buffer associated with module object
142 Handle<Object> obj(module_object->GetInternalField(kWasmMemArrayBuffer),
143 isolate);
144
145 if (obj->IsUndefined(isolate)) {
146 return isolate->heap()->undefined_value();
147 }
148
149 Handle<JSArrayBuffer> mem_buffer = Handle<JSArrayBuffer>::cast(obj);
150
151 wasm::WasmModule module(reinterpret_cast<byte*>(mem_buffer->backing_store()));
152 wasm::ErrorThrower thrower(isolate, "JITSingleFunction");
153 wasm::ModuleEnv module_env;
154 module_env.module = &module;
155 module_env.instance = nullptr;
156 module_env.origin = wasm::kWasmOrigin;
157
158 uint32_t signature_size = args.length() - fixed_args;
159 wasm::LocalType* sig_types = new wasm::LocalType[signature_size];
160
161 for (uint32_t i = 0; i < signature_size; ++i) {
162 CONVERT_SMI_ARG_CHECKED(sig_type, i + fixed_args);
163 sig_types[i] = static_cast<wasm::LocalType>(sig_type);
164 }
165 wasm::FunctionSig sig(return_count, signature_size - return_count, sig_types);
166
167 wasm::WasmFunction func;
168 func.sig = &sig;
169 func.func_index = index;
170 func.sig_index = sig_index;
171 func.name_offset = 0;
172 func.name_length = 0;
173 func.code_start_offset = base;
174 func.code_end_offset = base + length;
175
176 Handle<Code> code = compiler::WasmCompilationUnit::CompileWasmFunction(
177 &thrower, isolate, &module_env, &func);
178
179 delete[] sig_types;
180 if (thrower.error()) {
181 return isolate->heap()->undefined_value();
182 }
183
184 function_table->set(index, Smi::FromInt(sig_index));
185 function_table->set(index + function_table->length() / 2, *code);
186
187 return isolate->heap()->undefined_value();
188 }
189 } // namespace internal 112 } // namespace internal
190 } // namespace v8 113 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/ast-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698