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

Side by Side Diff: src/wasm/wasm-code-specialization.cc

Issue 2732273003: Disentangle assembler from isolate. (Closed)
Patch Set: Address feedback. Created 3 years, 9 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/snapshot/serializer.cc ('k') | src/wasm/wasm-debug.cc » ('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 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/wasm/wasm-code-specialization.h" 5 #include "src/wasm/wasm-code-specialization.h"
6 6
7 #include "src/assembler-inl.h" 7 #include "src/assembler-inl.h"
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 #include "src/source-position-table.h" 9 #include "src/source-position-table.h"
10 #include "src/wasm/decoder.h" 10 #include "src/wasm/decoder.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // There must be exactly one call to WASM_FUNCTION or WASM_TO_JS_FUNCTION. 142 // There must be exactly one call to WASM_FUNCTION or WASM_TO_JS_FUNCTION.
143 for (RelocIterator it(export_wrapper, 143 for (RelocIterator it(export_wrapper,
144 RelocInfo::ModeMask(RelocInfo::CODE_TARGET)); 144 RelocInfo::ModeMask(RelocInfo::CODE_TARGET));
145 ; it.next()) { 145 ; it.next()) {
146 DCHECK(!it.done()); 146 DCHECK(!it.done());
147 // Ignore calls to other builtins like ToNumber. 147 // Ignore calls to other builtins like ToNumber.
148 if (!IsAtWasmDirectCallTarget(it)) continue; 148 if (!IsAtWasmDirectCallTarget(it)) continue;
149 Code* new_code = Code::cast(code_table->get(exp.index)); 149 Code* new_code = Code::cast(code_table->get(exp.index));
150 DCHECK(new_code->kind() == Code::WASM_FUNCTION || 150 DCHECK(new_code->kind() == Code::WASM_FUNCTION ||
151 new_code->kind() == Code::WASM_TO_JS_FUNCTION); 151 new_code->kind() == Code::WASM_TO_JS_FUNCTION);
152 it.rinfo()->set_target_address(new_code->instruction_start(), 152 it.rinfo()->set_target_address(new_code->GetIsolate(),
153 new_code->instruction_start(),
153 UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH); 154 UPDATE_WRITE_BARRIER, SKIP_ICACHE_FLUSH);
154 break; 155 break;
155 } 156 }
156 changed = true; 157 changed = true;
157 func_index++; 158 func_index++;
158 } 159 }
159 DCHECK_EQ(code_table->length(), func_index); 160 DCHECK_EQ(code_table->length(), func_index);
160 return changed; 161 return changed;
161 } 162 }
162 163
(...skipping 21 matching lines...) Expand all
184 add_mode(reloc_objects, RelocInfo::EMBEDDED_OBJECT); 185 add_mode(reloc_objects, RelocInfo::EMBEDDED_OBJECT);
185 186
186 std::unique_ptr<PatchDirectCallsHelper> patch_direct_calls_helper; 187 std::unique_ptr<PatchDirectCallsHelper> patch_direct_calls_helper;
187 bool changed = false; 188 bool changed = false;
188 189
189 for (RelocIterator it(code, reloc_mode); !it.done(); it.next()) { 190 for (RelocIterator it(code, reloc_mode); !it.done(); it.next()) {
190 RelocInfo::Mode mode = it.rinfo()->rmode(); 191 RelocInfo::Mode mode = it.rinfo()->rmode();
191 switch (mode) { 192 switch (mode) {
192 case RelocInfo::WASM_MEMORY_REFERENCE: 193 case RelocInfo::WASM_MEMORY_REFERENCE:
193 DCHECK(reloc_mem_addr); 194 DCHECK(reloc_mem_addr);
194 it.rinfo()->update_wasm_memory_reference(old_mem_start, new_mem_start, 195 it.rinfo()->update_wasm_memory_reference(code->GetIsolate(),
196 old_mem_start, new_mem_start,
195 icache_flush_mode); 197 icache_flush_mode);
196 changed = true; 198 changed = true;
197 break; 199 break;
198 case RelocInfo::WASM_MEMORY_SIZE_REFERENCE: 200 case RelocInfo::WASM_MEMORY_SIZE_REFERENCE:
199 DCHECK(reloc_mem_size); 201 DCHECK(reloc_mem_size);
200 it.rinfo()->update_wasm_memory_size(old_mem_size, new_mem_size, 202 it.rinfo()->update_wasm_memory_size(code->GetIsolate(), old_mem_size,
201 icache_flush_mode); 203 new_mem_size, icache_flush_mode);
202 changed = true; 204 changed = true;
203 break; 205 break;
204 case RelocInfo::WASM_GLOBAL_REFERENCE: 206 case RelocInfo::WASM_GLOBAL_REFERENCE:
205 DCHECK(reloc_globals); 207 DCHECK(reloc_globals);
206 it.rinfo()->update_wasm_global_reference( 208 it.rinfo()->update_wasm_global_reference(
207 old_globals_start, new_globals_start, icache_flush_mode); 209 code->GetIsolate(), old_globals_start, new_globals_start,
210 icache_flush_mode);
208 changed = true; 211 changed = true;
209 break; 212 break;
210 case RelocInfo::CODE_TARGET: { 213 case RelocInfo::CODE_TARGET: {
211 DCHECK(reloc_direct_calls); 214 DCHECK(reloc_direct_calls);
212 // Skip everything which is not a wasm call (stack checks, traps, ...). 215 // Skip everything which is not a wasm call (stack checks, traps, ...).
213 if (!IsAtWasmDirectCallTarget(it)) continue; 216 if (!IsAtWasmDirectCallTarget(it)) continue;
214 // Iterate simultaneously over the relocation information and the source 217 // Iterate simultaneously over the relocation information and the source
215 // position table. For each call in the reloc info, move the source 218 // position table. For each call in the reloc info, move the source
216 // position iterator forward to that position to find the byte offset of 219 // position iterator forward to that position to find the byte offset of
217 // the respective call. Then extract the call index from the module wire 220 // the respective call. Then extract the call index from the module wire
218 // bytes to find the new compiled function. 221 // bytes to find the new compiled function.
219 size_t offset = it.rinfo()->pc() - code->instruction_start(); 222 size_t offset = it.rinfo()->pc() - code->instruction_start();
220 if (!patch_direct_calls_helper) { 223 if (!patch_direct_calls_helper) {
221 patch_direct_calls_helper.reset(new PatchDirectCallsHelper( 224 patch_direct_calls_helper.reset(new PatchDirectCallsHelper(
222 *relocate_direct_calls_instance, code)); 225 *relocate_direct_calls_instance, code));
223 } 226 }
224 int byte_pos = AdvanceSourcePositionTableIterator( 227 int byte_pos = AdvanceSourcePositionTableIterator(
225 patch_direct_calls_helper->source_pos_it, offset); 228 patch_direct_calls_helper->source_pos_it, offset);
226 int called_func_index = ExtractDirectCallIndex( 229 int called_func_index = ExtractDirectCallIndex(
227 patch_direct_calls_helper->decoder, 230 patch_direct_calls_helper->decoder,
228 patch_direct_calls_helper->func_bytes + byte_pos); 231 patch_direct_calls_helper->func_bytes + byte_pos);
229 FixedArray* code_table = 232 FixedArray* code_table =
230 relocate_direct_calls_instance->compiled_module() 233 relocate_direct_calls_instance->compiled_module()
231 ->ptr_to_code_table(); 234 ->ptr_to_code_table();
232 Code* new_code = Code::cast(code_table->get(called_func_index)); 235 Code* new_code = Code::cast(code_table->get(called_func_index));
233 it.rinfo()->set_target_address(new_code->instruction_start(), 236 it.rinfo()->set_target_address(new_code->GetIsolate(),
237 new_code->instruction_start(),
234 UPDATE_WRITE_BARRIER, icache_flush_mode); 238 UPDATE_WRITE_BARRIER, icache_flush_mode);
235 changed = true; 239 changed = true;
236 } break; 240 } break;
237 case RelocInfo::EMBEDDED_OBJECT: { 241 case RelocInfo::EMBEDDED_OBJECT: {
238 DCHECK(reloc_objects); 242 DCHECK(reloc_objects);
239 Object* old = it.rinfo()->target_object(); 243 Object* old = it.rinfo()->target_object();
240 Handle<Object>* new_obj = objects_to_relocate.Find(old); 244 Handle<Object>* new_obj = objects_to_relocate.Find(old);
241 if (new_obj) { 245 if (new_obj) {
242 it.rinfo()->set_target_object(HeapObject::cast(**new_obj), 246 it.rinfo()->set_target_object(HeapObject::cast(**new_obj),
243 UPDATE_WRITE_BARRIER, 247 UPDATE_WRITE_BARRIER,
244 icache_flush_mode); 248 icache_flush_mode);
245 changed = true; 249 changed = true;
246 } 250 }
247 } break; 251 } break;
248 case RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE: 252 case RelocInfo::WASM_FUNCTION_TABLE_SIZE_REFERENCE:
249 DCHECK(patch_table_size); 253 DCHECK(patch_table_size);
250 it.rinfo()->update_wasm_function_table_size_reference( 254 it.rinfo()->update_wasm_function_table_size_reference(
251 old_function_table_size, new_function_table_size, 255 code->GetIsolate(), old_function_table_size,
252 icache_flush_mode); 256 new_function_table_size, icache_flush_mode);
253 changed = true; 257 changed = true;
254 break; 258 break;
255 default: 259 default:
256 UNREACHABLE(); 260 UNREACHABLE();
257 } 261 }
258 } 262 }
259 263
260 return changed; 264 return changed;
261 } 265 }
OLDNEW
« no previous file with comments | « src/snapshot/serializer.cc ('k') | src/wasm/wasm-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698