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

Side by Side Diff: src/wasm/encoder.cc

Issue 2165633006: [wasm] Remove special memory type for (internal) globals and use local type instead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] Remove special memory type for (internal) globals and use local type instead. Created 4 years, 5 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
« no previous file with comments | « src/wasm/encoder.h ('k') | src/wasm/module-decoder.cc » ('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-containers.h" 9 #include "src/zone-containers.h"
10 10
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length, 240 uint32_t WasmModuleBuilder::AddImport(const char* name, int name_length,
241 FunctionSig* sig) { 241 FunctionSig* sig) {
242 imports_.push_back({AddSignature(sig), name, name_length}); 242 imports_.push_back({AddSignature(sig), name, name_length});
243 return static_cast<uint32_t>(imports_.size() - 1); 243 return static_cast<uint32_t>(imports_.size() - 1);
244 } 244 }
245 245
246 void WasmModuleBuilder::MarkStartFunction(uint32_t index) { 246 void WasmModuleBuilder::MarkStartFunction(uint32_t index) {
247 start_function_index_ = index; 247 start_function_index_ = index;
248 } 248 }
249 249
250 uint32_t WasmModuleBuilder::AddGlobal(MachineType type, bool exported) { 250 uint32_t WasmModuleBuilder::AddGlobal(LocalType type, bool exported) {
251 globals_.push_back(std::make_pair(type, exported)); 251 globals_.push_back(std::make_pair(type, exported));
252 return static_cast<uint32_t>(globals_.size() - 1); 252 return static_cast<uint32_t>(globals_.size() - 1);
253 } 253 }
254 254
255 void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const { 255 void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
256 uint32_t exports = 0; 256 uint32_t exports = 0;
257 257
258 // == Emit magic ============================================================= 258 // == Emit magic =============================================================
259 TRACE("emit magic\n"); 259 TRACE("emit magic\n");
260 buffer.write_u32(kWasmMagic); 260 buffer.write_u32(kWasmMagic);
(...skipping 18 matching lines...) Expand all
279 FixupSection(buffer, start); 279 FixupSection(buffer, start);
280 } 280 }
281 281
282 // == Emit globals =========================================================== 282 // == Emit globals ===========================================================
283 if (globals_.size() > 0) { 283 if (globals_.size() > 0) {
284 size_t start = EmitSection(WasmSection::Code::Globals, buffer); 284 size_t start = EmitSection(WasmSection::Code::Globals, buffer);
285 buffer.write_size(globals_.size()); 285 buffer.write_size(globals_.size());
286 286
287 for (auto global : globals_) { 287 for (auto global : globals_) {
288 buffer.write_u32v(0); // Length of the global name. 288 buffer.write_u32v(0); // Length of the global name.
289 buffer.write_u8(WasmOpcodes::MemTypeCodeFor(global.first)); 289 buffer.write_u8(WasmOpcodes::LocalTypeCodeFor(global.first));
290 buffer.write_u8(global.second); 290 buffer.write_u8(global.second);
291 } 291 }
292 FixupSection(buffer, start); 292 FixupSection(buffer, start);
293 } 293 }
294 294
295 // == Emit imports =========================================================== 295 // == Emit imports ===========================================================
296 if (imports_.size() > 0) { 296 if (imports_.size() > 0) {
297 size_t start = EmitSection(WasmSection::Code::ImportTable, buffer); 297 size_t start = EmitSection(WasmSection::Code::ImportTable, buffer);
298 buffer.write_size(imports_.size()); 298 buffer.write_size(imports_.size());
299 for (auto import : imports_) { 299 for (auto import : imports_) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 for (auto segment : data_segments_) { 374 for (auto segment : data_segments_) {
375 segment->Write(buffer); 375 segment->Write(buffer);
376 } 376 }
377 FixupSection(buffer, start); 377 FixupSection(buffer, start);
378 } 378 }
379 } 379 }
380 } // namespace wasm 380 } // namespace wasm
381 } // namespace internal 381 } // namespace internal
382 } // namespace v8 382 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/encoder.h ('k') | src/wasm/module-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698