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

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

Issue 2021323003: [wasm] remove faux code objects Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include "src/isolate-inl.h" 7 #include "src/isolate-inl.h"
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 1901
1902 *effect_ = call; 1902 *effect_ = call;
1903 return call; 1903 return call;
1904 } 1904 }
1905 1905
1906 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, 1906 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args,
1907 wasm::WasmCodePosition position) { 1907 wasm::WasmCodePosition position) {
1908 DCHECK_NULL(args[0]); 1908 DCHECK_NULL(args[0]);
1909 1909
1910 // Add code object as constant. 1910 // Add code object as constant.
1911 args[0] = HeapConstant(module_->GetCodeOrPlaceholder(index)); 1911 args[0] =
1912 jsgraph()->RelocatableInt32Constant(index, RelocInfo::WASM_DIRECT_CALL);
1912 wasm::FunctionSig* sig = module_->GetFunctionSignature(index); 1913 wasm::FunctionSig* sig = module_->GetFunctionSignature(index);
1913 1914
1914 return BuildWasmCall(sig, args, position); 1915 return BuildWasmCall(sig, args, position);
1915 } 1916 }
1916 1917
1917 Node* WasmGraphBuilder::CallImport(uint32_t index, Node** args, 1918 Node* WasmGraphBuilder::CallImport(uint32_t index, Node** args,
1918 wasm::WasmCodePosition position) { 1919 wasm::WasmCodePosition position) {
1919 DCHECK_NULL(args[0]); 1920 DCHECK_NULL(args[0]);
1920 1921
1921 // Add code object as constant. 1922 // Add code object as constant.
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3302 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); 3303 double compile_ms = compile_timer.Elapsed().InMillisecondsF();
3303 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n", 3304 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n",
3304 static_cast<int>(function_->code_end_offset - 3305 static_cast<int>(function_->code_end_offset -
3305 function_->code_start_offset), 3306 function_->code_start_offset),
3306 compile_ms); 3307 compile_ms);
3307 } 3308 }
3308 3309
3309 return code; 3310 return code;
3310 } 3311 }
3311 3312
3313 void Link(Isolate* isolate, std::vector<Handle<Code>>& functions) {
ahaas 2016/06/02 13:48:27 What's the reason why you move the code for linkin
Mircea Trofin 2016/06/02 14:46:21 I didn't realize that was the separation. I though
3314 // On architectures supporting constant pools, if a function A calls another
3315 // function B in a number of places, then the same slot in the constant pool
3316 // would be used for the call to B. We can't update eagerly the location,
3317 // because that would mean that the next time we look at the location to find
3318 // the index of the function being called, we'd find the actual address
3319 // instead. So we keep a worklist. To keep the code simple, we maintain the
3320 // worklist even on architectures that do not support constant pools.
3321 std::vector<std::pair<RelocInfo, Address>> worklist;
3322 for (Handle<Code> code : functions) {
3323 int mode_mask = RelocInfo::kWasmDirectCallMask;
3324 AllowDeferredHandleDereference embedding_raw_address;
3325 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) {
3326 size_t f_index = it.rinfo()->wasm_function_index();
3327 Handle<Code> code = functions[f_index];
3328 worklist.push_back(
3329 std::make_pair(*it.rinfo(), code->instruction_start()));
3330 }
3331 for (auto pair : worklist) {
3332 pair.first.set_target_address(pair.second, SKIP_WRITE_BARRIER,
3333 SKIP_ICACHE_FLUSH);
3334 }
3335 if (!worklist.empty()) {
3336 worklist.clear();
3337 Assembler::FlushICache(isolate, code->instruction_start(),
3338 code->instruction_size());
3339 }
3340 }
3341 }
3342
3312 } // namespace compiler 3343 } // namespace compiler
3313 } // namespace internal 3344 } // namespace internal
3314 } // namespace v8 3345 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698