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

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

Issue 2563613003: Revert of [wasm] Fix location for error in asm.js ToNumber conversion (Closed)
Patch Set: 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 call_position, 153 void WasmFunctionBuilder::AddAsmWasmOffset(int asm_position) {
154 int to_number_position) {
155 // We only want to emit one mapping per byte offset: 154 // We only want to emit one mapping per byte offset:
156 DCHECK(asm_offsets_.size() == 0 || body_.size() > last_asm_byte_offset_); 155 DCHECK(asm_offsets_.size() == 0 || body_.size() > last_asm_byte_offset_);
157 156
158 DCHECK_LE(body_.size(), kMaxUInt32); 157 DCHECK_LE(body_.size(), kMaxUInt32);
159 uint32_t byte_offset = static_cast<uint32_t>(body_.size()); 158 uint32_t byte_offset = static_cast<uint32_t>(body_.size());
160 asm_offsets_.write_u32v(byte_offset - last_asm_byte_offset_); 159 asm_offsets_.write_u32v(byte_offset - last_asm_byte_offset_);
161 last_asm_byte_offset_ = byte_offset; 160 last_asm_byte_offset_ = byte_offset;
162 161
163 DCHECK_GE(call_position, 0); 162 DCHECK_GE(asm_position, 0);
164 asm_offsets_.write_i32v(call_position - last_asm_source_position_); 163 asm_offsets_.write_i32v(asm_position - last_asm_source_position_);
165 164 last_asm_source_position_ = asm_position;
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;
169 } 165 }
170 166
171 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const { 167 void WasmFunctionBuilder::WriteSignature(ZoneBuffer& buffer) const {
172 buffer.write_u32v(signature_index_); 168 buffer.write_u32v(signature_index_);
173 } 169 }
174 170
175 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const { 171 void WasmFunctionBuilder::WriteExports(ZoneBuffer& buffer) const {
176 for (auto name : exported_names_) { 172 for (auto name : exported_names_) {
177 buffer.write_size(name.size()); 173 buffer.write_size(name.size());
178 buffer.write(reinterpret_cast<const byte*>(name.data()), name.size()); 174 buffer.write(reinterpret_cast<const byte*>(name.data()), name.size());
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Emit the offset table per function. 531 // Emit the offset table per function.
536 for (auto function : functions_) { 532 for (auto function : functions_) {
537 function->WriteAsmWasmOffsetTable(buffer); 533 function->WriteAsmWasmOffsetTable(buffer);
538 } 534 }
539 // Append a 0 to indicate that this is an encoded table. 535 // Append a 0 to indicate that this is an encoded table.
540 buffer.write_u8(0); 536 buffer.write_u8(0);
541 } 537 }
542 } // namespace wasm 538 } // namespace wasm
543 } // namespace internal 539 } // namespace internal
544 } // namespace v8 540 } // 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