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

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

Issue 2500443004: [wasm] OOB traps: build protected instruction list during codegen (Closed)
Patch Set: Merging with master Created 4 years, 1 month 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 <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 3412 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 } 3423 }
3424 3424
3425 // Run the compiler pipeline to generate machine code. 3425 // Run the compiler pipeline to generate machine code.
3426 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor( 3426 CallDescriptor* descriptor = wasm::ModuleEnv::GetWasmCallDescriptor(
3427 &compilation_zone_, function_->sig); 3427 &compilation_zone_, function_->sig);
3428 if (jsgraph_->machine()->Is32()) { 3428 if (jsgraph_->machine()->Is32()) {
3429 descriptor = 3429 descriptor =
3430 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor); 3430 module_env_->GetI32WasmCallDescriptor(&compilation_zone_, descriptor);
3431 } 3431 }
3432 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(), 3432 job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(),
3433 descriptor, source_positions)); 3433 descriptor, source_positions,
3434 &protected_instructions_));
3434 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED; 3435 ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
3435 // TODO(bradnelson): Improve histogram handling of size_t. 3436 // TODO(bradnelson): Improve histogram handling of size_t.
3436 // TODO(ahaas): The counters are not thread-safe at the moment. 3437 // TODO(ahaas): The counters are not thread-safe at the moment.
3437 // isolate_->counters()->wasm_compile_function_peak_memory_bytes() 3438 // isolate_->counters()->wasm_compile_function_peak_memory_bytes()
3438 // ->AddSample( 3439 // ->AddSample(
3439 // static_cast<int>(jsgraph->graph()->zone()->allocation_size())); 3440 // static_cast<int>(jsgraph->graph()->zone()->allocation_size()));
3440 3441
3441 if (FLAG_trace_wasm_decode_time) { 3442 if (FLAG_trace_wasm_decode_time) {
3442 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF(); 3443 double pipeline_ms = pipeline_timer.Elapsed().InMillisecondsF();
3443 PrintF( 3444 PrintF(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3483 } 3484 }
3484 3485
3485 if (FLAG_trace_wasm_decode_time) { 3486 if (FLAG_trace_wasm_decode_time) {
3486 double compile_ms = compile_timer.Elapsed().InMillisecondsF(); 3487 double compile_ms = compile_timer.Elapsed().InMillisecondsF();
3487 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n", 3488 PrintF("wasm-code-generation ok: %d bytes, %0.3f ms code generation\n",
3488 static_cast<int>(function_->code_end_offset - 3489 static_cast<int>(function_->code_end_offset -
3489 function_->code_start_offset), 3490 function_->code_start_offset),
3490 compile_ms); 3491 compile_ms);
3491 } 3492 }
3492 3493
3494 Handle<FixedArray> protected_instructions = PackProtectedInstructions();
3495 code->set_protected_instructions(*protected_instructions);
3496
3493 return code; 3497 return code;
3494 } 3498 }
3495 3499
3500 Handle<FixedArray> WasmCompilationUnit::PackProtectedInstructions() const {
3501 const int num_instructions = static_cast<int>(protected_instructions_.size());
3502 Handle<FixedArray> fn_protected = isolate_->factory()->NewFixedArray(
3503 num_instructions * wasm::kTrapDataSize, TENURED);
3504 for (unsigned i = 0; i < protected_instructions_.size(); ++i) {
3505 const ProtectedInstructionData& instruction = protected_instructions_[i];
3506 fn_protected->set(wasm::kTrapDataSize * i + wasm::kTrapCodeOffset,
3507 Smi::FromInt(instruction.instr_offset));
3508 fn_protected->set(wasm::kTrapDataSize * i + wasm::kTrapLandingOffset,
3509 Smi::FromInt(instruction.landing_offset));
3510 }
3511 return fn_protected;
3512 }
3513
3496 } // namespace compiler 3514 } // namespace compiler
3497 } // namespace internal 3515 } // namespace internal
3498 } // namespace v8 3516 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698