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

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

Issue 1609893002: Add function tables to asm to wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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') | test/cctest/test-asm-validator.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 body_.push_back(static_cast<byte>(opcode)); 114 body_.push_back(static_cast<byte>(opcode));
115 } 115 }
116 116
117 117
118 void WasmFunctionBuilder::EmitWithU8(WasmOpcode opcode, const byte immediate) { 118 void WasmFunctionBuilder::EmitWithU8(WasmOpcode opcode, const byte immediate) {
119 body_.push_back(static_cast<byte>(opcode)); 119 body_.push_back(static_cast<byte>(opcode));
120 body_.push_back(immediate); 120 body_.push_back(immediate);
121 } 121 }
122 122
123 123
124 void WasmFunctionBuilder::EmitWithLocal(WasmOpcode opcode) {
125 body_.push_back(static_cast<byte>(opcode));
126 local_indices_.push_back(static_cast<uint32_t>(body_.size()) - 1);
127 }
128
129
130 uint32_t WasmFunctionBuilder::EmitEditableImmediate(const byte immediate) { 124 uint32_t WasmFunctionBuilder::EmitEditableImmediate(const byte immediate) {
131 body_.push_back(immediate); 125 body_.push_back(immediate);
132 return static_cast<uint32_t>(body_.size()) - 1; 126 return static_cast<uint32_t>(body_.size()) - 1;
133 } 127 }
134 128
135 129
136 void WasmFunctionBuilder::EditImmediate(uint32_t offset, const byte immediate) { 130 void WasmFunctionBuilder::EditImmediate(uint32_t offset, const byte immediate) {
137 DCHECK(offset < body_.size()); 131 DCHECK(offset < body_.size());
138 body_[offset] = immediate; 132 body_[offset] = immediate;
139 } 133 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 return nullptr; 357 return nullptr;
364 } 358 }
365 } 359 }
366 360
367 361
368 void WasmModuleBuilder::AddDataSegment(WasmDataSegmentEncoder* data) { 362 void WasmModuleBuilder::AddDataSegment(WasmDataSegmentEncoder* data) {
369 data_segments_.push_back(data); 363 data_segments_.push_back(data);
370 } 364 }
371 365
372 366
373 int WasmModuleBuilder::CompareFunctionSigs::operator()(FunctionSig* a, 367 bool WasmModuleBuilder::CompareFunctionSigs::operator()(FunctionSig* a,
374 FunctionSig* b) const { 368 FunctionSig* b) const {
375 if (a->return_count() < b->return_count()) return -1; 369 if (a->return_count() < b->return_count()) return true;
376 if (a->return_count() > b->return_count()) return 1; 370 if (a->return_count() > b->return_count()) return false;
377 if (a->parameter_count() < b->parameter_count()) return -1; 371 if (a->parameter_count() < b->parameter_count()) return true;
378 if (a->parameter_count() > b->parameter_count()) return 1; 372 if (a->parameter_count() > b->parameter_count()) return false;
379 for (size_t r = 0; r < a->return_count(); r++) { 373 for (size_t r = 0; r < a->return_count(); r++) {
380 if (a->GetReturn(r) < b->GetReturn(r)) return -1; 374 if (a->GetReturn(r) < b->GetReturn(r)) return true;
381 if (a->GetReturn(r) > b->GetReturn(r)) return 1; 375 if (a->GetReturn(r) > b->GetReturn(r)) return false;
382 } 376 }
383 for (size_t p = 0; p < a->parameter_count(); p++) { 377 for (size_t p = 0; p < a->parameter_count(); p++) {
384 if (a->GetParam(p) < b->GetParam(p)) return -1; 378 if (a->GetParam(p) < b->GetParam(p)) return true;
385 if (a->GetParam(p) > b->GetParam(p)) return 1; 379 if (a->GetParam(p) > b->GetParam(p)) return false;
386 } 380 }
387 return 0; 381 return false;
388 } 382 }
389 383
390 384
391 uint16_t WasmModuleBuilder::AddSignature(FunctionSig* sig) { 385 uint16_t WasmModuleBuilder::AddSignature(FunctionSig* sig) {
392 SignatureMap::iterator pos = signature_map_.find(sig); 386 SignatureMap::iterator pos = signature_map_.find(sig);
393 if (pos != signature_map_.end()) { 387 if (pos != signature_map_.end()) {
394 return pos->second; 388 return pos->second;
395 } else { 389 } else {
396 uint16_t index = static_cast<uint16_t>(signatures_.size()); 390 uint16_t index = static_cast<uint16_t>(signatures_.size());
397 signature_map_[sig] = index; 391 signature_map_[sig] = index;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 next = next | 0x80; 577 next = next | 0x80;
584 } 578 }
585 output.push_back(next); 579 output.push_back(next);
586 shift += 7; 580 shift += 7;
587 } while ((next & 0x80) != 0); 581 } while ((next & 0x80) != 0);
588 return output; 582 return output;
589 } 583 }
590 } // namespace wasm 584 } // namespace wasm
591 } // namespace internal 585 } // namespace internal
592 } // namespace v8 586 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/encoder.h ('k') | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698