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

Side by Side Diff: src/wasm/ast-decoder.cc

Issue 1890803002: [wasm] Generate source position information (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-throw-error
Patch Set: avoid using std::tie 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
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | test/cctest/wasm/test-run-wasm.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/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 if (count == 0) { 711 if (count == 0) {
712 BUILD(Return, 0, builder_->Buffer(0)); 712 BUILD(Return, 0, builder_->Buffer(0));
713 ssa_env_->Kill(); 713 ssa_env_->Kill();
714 Leaf(kAstEnd); 714 Leaf(kAstEnd);
715 } else { 715 } else {
716 Shift(kAstEnd, count); 716 Shift(kAstEnd, count);
717 } 717 }
718 break; 718 break;
719 } 719 }
720 case kExprUnreachable: { 720 case kExprUnreachable: {
721 // TODO(clemensh): add source position for unreachable
721 BUILD0(Unreachable); 722 BUILD0(Unreachable);
722 ssa_env_->Kill(SsaEnv::kControlEnd); 723 ssa_env_->Kill(SsaEnv::kControlEnd);
723 Leaf(kAstEnd, nullptr); 724 Leaf(kAstEnd, nullptr);
724 break; 725 break;
725 } 726 }
726 case kExprI8Const: { 727 case kExprI8Const: {
727 ImmI8Operand operand(this, pc_); 728 ImmI8Operand operand(this, pc_);
728 Leaf(kAstI32, BUILD(Int32Constant, operand.value)); 729 Leaf(kAstI32, BUILD(Int32Constant, operand.value));
729 len = 1 + operand.length; 730 len = 1 + operand.length;
730 break; 731 break;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 TypeCheckLast(p, operand.sig->GetParam(p->index - 1)); 1229 TypeCheckLast(p, operand.sig->GetParam(p->index - 1));
1229 } 1230 }
1230 if (p->done() && build()) { 1231 if (p->done() && build()) {
1231 uint32_t count = p->tree->count + 1; 1232 uint32_t count = p->tree->count + 1;
1232 TFNode** buffer = builder_->Buffer(count); 1233 TFNode** buffer = builder_->Buffer(count);
1233 buffer[0] = nullptr; // reserved for code object. 1234 buffer[0] = nullptr; // reserved for code object.
1234 for (uint32_t i = 1; i < count; i++) { 1235 for (uint32_t i = 1; i < count; i++) {
1235 buffer[i] = p->tree->children[i - 1]->node; 1236 buffer[i] = p->tree->children[i - 1]->node;
1236 } 1237 }
1237 p->tree->node = builder_->CallDirect(operand.index, buffer); 1238 p->tree->node = builder_->CallDirect(operand.index, buffer);
1239 AddSourcePosition(p);
1238 } 1240 }
1239 break; 1241 break;
1240 } 1242 }
1241 case kExprCallIndirect: { 1243 case kExprCallIndirect: {
1242 SignatureIndexOperand operand(this, p->pc()); 1244 SignatureIndexOperand operand(this, p->pc());
1243 CHECK(Validate(p->pc(), operand)); 1245 CHECK(Validate(p->pc(), operand));
1244 if (p->index == 1) { 1246 if (p->index == 1) {
1245 TypeCheckLast(p, kAstI32); 1247 TypeCheckLast(p, kAstI32);
1246 } else { 1248 } else {
1247 TypeCheckLast(p, operand.sig->GetParam(p->index - 2)); 1249 TypeCheckLast(p, operand.sig->GetParam(p->index - 2));
1248 } 1250 }
1249 if (p->done() && build()) { 1251 if (p->done() && build()) {
1250 uint32_t count = p->tree->count; 1252 uint32_t count = p->tree->count;
1251 TFNode** buffer = builder_->Buffer(count); 1253 TFNode** buffer = builder_->Buffer(count);
1252 for (uint32_t i = 0; i < count; i++) { 1254 for (uint32_t i = 0; i < count; i++) {
1253 buffer[i] = p->tree->children[i]->node; 1255 buffer[i] = p->tree->children[i]->node;
1254 } 1256 }
1255 p->tree->node = builder_->CallIndirect(operand.index, buffer); 1257 p->tree->node = builder_->CallIndirect(operand.index, buffer);
1258 AddSourcePosition(p);
1256 } 1259 }
1257 break; 1260 break;
1258 } 1261 }
1259 case kExprCallImport: { 1262 case kExprCallImport: {
1260 ImportIndexOperand operand(this, p->pc()); 1263 ImportIndexOperand operand(this, p->pc());
1261 CHECK(Validate(p->pc(), operand)); 1264 CHECK(Validate(p->pc(), operand));
1262 if (p->index > 0) { 1265 if (p->index > 0) {
1263 TypeCheckLast(p, operand.sig->GetParam(p->index - 1)); 1266 TypeCheckLast(p, operand.sig->GetParam(p->index - 1));
1264 } 1267 }
1265 if (p->done() && build()) { 1268 if (p->done() && build()) {
1266 uint32_t count = p->tree->count + 1; 1269 uint32_t count = p->tree->count + 1;
1267 TFNode** buffer = builder_->Buffer(count); 1270 TFNode** buffer = builder_->Buffer(count);
1268 buffer[0] = nullptr; // reserved for code object. 1271 buffer[0] = nullptr; // reserved for code object.
1269 for (uint32_t i = 1; i < count; i++) { 1272 for (uint32_t i = 1; i < count; i++) {
1270 buffer[i] = p->tree->children[i - 1]->node; 1273 buffer[i] = p->tree->children[i - 1]->node;
1271 } 1274 }
1272 p->tree->node = builder_->CallImport(operand.index, buffer); 1275 p->tree->node = builder_->CallImport(operand.index, buffer);
1276 AddSourcePosition(p);
1273 } 1277 }
1274 break; 1278 break;
1275 } 1279 }
1276 default: 1280 default:
1277 break; 1281 break;
1278 } 1282 }
1279 } 1283 }
1280 1284
1281 void ReduceBreakToExprBlock(Production* p, Block* block) { 1285 void ReduceBreakToExprBlock(Production* p, Block* block) {
1282 ReduceBreakToExprBlock(p, block, p->tree->count > 0 ? p->last() : nullptr); 1286 ReduceBreakToExprBlock(p, block, p->tree->count > 0 ? p->last() : nullptr);
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 pc += length; 1628 pc += length;
1625 arity_stack.push_back(arity); 1629 arity_stack.push_back(arity);
1626 while (arity_stack.back() == 0) { 1630 while (arity_stack.back() == 0) {
1627 arity_stack.pop_back(); 1631 arity_stack.pop_back();
1628 if (arity_stack.empty()) return assigned; // reached end of loop 1632 if (arity_stack.empty()) return assigned; // reached end of loop
1629 arity_stack.back()--; 1633 arity_stack.back()--;
1630 } 1634 }
1631 } 1635 }
1632 return assigned; 1636 return assigned;
1633 } 1637 }
1638
1639 void AddSourcePosition(Production* p) {
1640 DCHECK_NOT_NULL(p->tree->node);
1641 AddSourcePosition(p->tree->node, p->pc());
1642 }
1643
1644 void AddSourcePosition(TFNode* node, const byte* pc) {
1645 int offset = static_cast<int>(pc - start_);
1646 DCHECK_EQ(pc - start_, offset); // overflows cannot happen
1647 builder_->SetSourcePosition(node, offset);
1648 }
1634 }; 1649 };
1635 1650
1636 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start, 1651 bool DecodeLocalDecls(AstLocalDecls& decls, const byte* start,
1637 const byte* end) { 1652 const byte* end) {
1638 base::AccountingAllocator allocator; 1653 base::AccountingAllocator allocator;
1639 Zone tmp(&allocator); 1654 Zone tmp(&allocator);
1640 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 1655 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
1641 SR_WasmDecoder decoder(&tmp, nullptr, body); 1656 SR_WasmDecoder decoder(&tmp, nullptr, body);
1642 return decoder.DecodeLocalDecls(decls); 1657 return decoder.DecodeLocalDecls(decls);
1643 } 1658 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 1791 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
1777 const byte* start, const byte* end) { 1792 const byte* start, const byte* end) {
1778 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 1793 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
1779 SR_WasmDecoder decoder(zone, nullptr, body); 1794 SR_WasmDecoder decoder(zone, nullptr, body);
1780 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); 1795 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
1781 } 1796 }
1782 1797
1783 } // namespace wasm 1798 } // namespace wasm
1784 } // namespace internal 1799 } // namespace internal
1785 } // namespace v8 1800 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698