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

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

Issue 1921203002: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable pointers to update wasm memory … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 2494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2505 reinterpret_cast<uintptr_t>(module_->instance->mem_start + offset), 2505 reinterpret_cast<uintptr_t>(module_->instance->mem_start + offset),
2506 RelocInfo::WASM_MEMORY_REFERENCE); 2506 RelocInfo::WASM_MEMORY_REFERENCE);
2507 } 2507 }
2508 } 2508 }
2509 2509
2510 2510
2511 Node* WasmGraphBuilder::MemSize(uint32_t offset) { 2511 Node* WasmGraphBuilder::MemSize(uint32_t offset) {
2512 DCHECK(module_ && module_->instance); 2512 DCHECK(module_ && module_->instance);
2513 uint32_t size = static_cast<uint32_t>(module_->instance->mem_size); 2513 uint32_t size = static_cast<uint32_t>(module_->instance->mem_size);
2514 if (offset == 0) { 2514 if (offset == 0) {
2515 if (!mem_size_) mem_size_ = jsgraph()->Int32Constant(size); 2515 if (!mem_size_)
2516 mem_size_ = jsgraph()->RelocatableInt32Constant(
2517 size, RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
2516 return mem_size_; 2518 return mem_size_;
2517 } else { 2519 } else {
2518 return jsgraph()->Int32Constant(size + offset); 2520 return jsgraph()->RelocatableInt32Constant(
2521 size + offset, RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
2519 } 2522 }
2520 } 2523 }
2521 2524
2522 2525
2523 Node* WasmGraphBuilder::FunctionTable() { 2526 Node* WasmGraphBuilder::FunctionTable() {
2524 DCHECK(module_ && module_->instance && 2527 DCHECK(module_ && module_->instance &&
2525 !module_->instance->function_table.is_null()); 2528 !module_->instance->function_table.is_null());
2526 if (!function_table_) { 2529 if (!function_table_) {
2527 function_table_ = jsgraph()->Constant(module_->instance->function_table); 2530 function_table_ = jsgraph()->Constant(module_->instance->function_table);
2528 } 2531 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2566 size_t size = module_->instance->mem_size; 2569 size_t size = module_->instance->mem_size;
2567 byte memsize = wasm::WasmOpcodes::MemSize(memtype); 2570 byte memsize = wasm::WasmOpcodes::MemSize(memtype);
2568 Node* cond; 2571 Node* cond;
2569 if (offset >= size || (static_cast<uint64_t>(offset) + memsize) > size) { 2572 if (offset >= size || (static_cast<uint64_t>(offset) + memsize) > size) {
2570 // The access will always throw. 2573 // The access will always throw.
2571 cond = jsgraph()->Int32Constant(0); 2574 cond = jsgraph()->Int32Constant(0);
2572 } else { 2575 } else {
2573 // Check against the limit. 2576 // Check against the limit.
2574 size_t limit = size - offset - memsize; 2577 size_t limit = size - offset - memsize;
2575 CHECK(limit <= kMaxUInt32); 2578 CHECK(limit <= kMaxUInt32);
2576 cond = graph()->NewNode( 2579 cond = graph()->NewNode(jsgraph()->machine()->Uint32LessThanOrEqual(),
2577 jsgraph()->machine()->Uint32LessThanOrEqual(), index, 2580 index, jsgraph()->RelocatableInt32Constant(
2578 jsgraph()->Int32Constant(static_cast<uint32_t>(limit))); 2581 static_cast<uint32_t>(limit),
2582 RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
2579 } 2583 }
2580 2584
2581 trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond); 2585 trap_->AddTrapIfFalse(wasm::kTrapMemOutOfBounds, cond);
2582 } 2586 }
2583 2587
2584 2588
2585 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype, 2589 Node* WasmGraphBuilder::LoadMem(wasm::LocalType type, MachineType memtype,
2586 Node* index, uint32_t offset) { 2590 Node* index, uint32_t offset) {
2587 Node* load; 2591 Node* load;
2588 2592
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2964 // TODO(bradnelson): Improve histogram handling of size_t. 2968 // TODO(bradnelson): Improve histogram handling of size_t.
2965 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample( 2969 isolate->counters()->wasm_compile_function_peak_memory_bytes()->AddSample(
2966 static_cast<int>(zone.allocation_size())); 2970 static_cast<int>(zone.allocation_size()));
2967 return code; 2971 return code;
2968 } 2972 }
2969 2973
2970 2974
2971 } // namespace compiler 2975 } // namespace compiler
2972 } // namespace internal 2976 } // namespace internal
2973 } // namespace v8 2977 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698