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

Side by Side Diff: src/wasm/wasm-module-builder.cc

Issue 2555243002: [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: Fix gc error by storing callee_pc_address Created 4 years 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/wasm/wasm-module-builder.h ('k') | src/wasm/wasm-objects.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 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/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/handles.h" 7 #include "src/handles.h"
8 #include "src/v8.h" 8 #include "src/v8.h"
9 #include "src/zone/zone-containers.h" 9 #include "src/zone/zone-containers.h"
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void WasmFunctionBuilder::ExportAs(Vector<const char> name) { 143 void WasmFunctionBuilder::ExportAs(Vector<const char> name) {
144 exported_names_.push_back(ZoneVector<char>( 144 exported_names_.push_back(ZoneVector<char>(
145 name.start(), name.start() + name.length(), builder_->zone())); 145 name.start(), name.start() + name.length(), builder_->zone()));
146 } 146 }
147 147
148 void WasmFunctionBuilder::SetName(Vector<const char> name) { 148 void WasmFunctionBuilder::SetName(Vector<const char> name) {
149 name_.resize(name.length()); 149 name_.resize(name.length());
150 memcpy(name_.data(), name.start(), name.length()); 150 memcpy(name_.data(), name.start(), name.length());
151 } 151 }
152 152
153 void WasmFunctionBuilder::AddAsmWasmOffset(int asm_position) { 153 void WasmFunctionBuilder::AddAsmWasmOffset(int call_position,
154 int to_number_position) {
154 // We only want to emit one mapping per byte offset: 155 // We only want to emit one mapping per byte offset:
155 DCHECK(asm_offsets_.size() == 0 || body_.size() > last_asm_byte_offset_); 156 DCHECK(asm_offsets_.size() == 0 || body_.size() > last_asm_byte_offset_);
156 157
157 DCHECK_LE(body_.size(), kMaxUInt32); 158 DCHECK_LE(body_.size(), kMaxUInt32);
158 uint32_t byte_offset = static_cast<uint32_t>(body_.size()); 159 uint32_t byte_offset = static_cast<uint32_t>(body_.size());
159 asm_offsets_.write_u32v(byte_offset - last_asm_byte_offset_); 160 asm_offsets_.write_u32v(byte_offset - last_asm_byte_offset_);
160 last_asm_byte_offset_ = byte_offset; 161 last_asm_byte_offset_ = byte_offset;
161 162
162 DCHECK_GE(asm_position, 0); 163 DCHECK_GE(call_position, 0);
163 asm_offsets_.write_i32v(asm_position - last_asm_source_position_); 164 asm_offsets_.write_i32v(call_position - last_asm_source_position_);
164 last_asm_source_position_ = asm_position; 165
166 DCHECK_GE(to_number_position, 0);
167 asm_offsets_.write_i32v(to_number_position - call_position);
168 last_asm_source_position_ = to_number_position;
165 } 169 }
166 170
167 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { 171 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const {
168 buffer.write_u32v(signature_index_); 172 buffer.write_u32v(signature_index_);
169 } 173 }
170 174
171 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { 175 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const {
172 for (auto name : exported_names_) { 176 for (auto name : exported_names_) {
173 buffer.write_size(name.size()); 177 buffer.write_size(name.size());
174 buffer.write(reinterpret_cast<const byte*>(name.data()), name.size()); 178 buffer.write(reinterpret_cast<const byte*>(name.data()), name.size());
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Emit the offset table per function. 535 // Emit the offset table per function.
532 for (auto function : functions_) { 536 for (auto function : functions_) {
533 function->WriteAsmWasmOffsetTable(buffer); 537 function->WriteAsmWasmOffsetTable(buffer);
534 } 538 }
535 // Append a 0 to indicate that this is an encoded table. 539 // Append a 0 to indicate that this is an encoded table.
536 buffer.write_u8(0); 540 buffer.write_u8(0);
537 } 541 }
538 } // namespace wasm 542 } // namespace wasm
539 } // namespace internal 543 } // namespace internal
540 } // namespace v8 544 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-module-builder.h ('k') | src/wasm/wasm-objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698