Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 return 1 + operand.arity; | 280 return 1 + operand.arity; |
| 281 } | 281 } |
| 282 | 282 |
| 283 case kExprIf: | 283 case kExprIf: |
| 284 return 1; | 284 return 1; |
| 285 case kExprSelect: | 285 case kExprSelect: |
| 286 return 3; | 286 return 3; |
| 287 | 287 |
| 288 case kExprCallFunction: { | 288 case kExprCallFunction: { |
| 289 CallFunctionOperand operand(this, pc); | 289 CallFunctionOperand operand(this, pc); |
| 290 return static_cast<int>( | 290 return operand.arity; |
|
ahaas
2016/05/02 14:48:28
Could the arity be calculated in a static function
titzer
2016/05/02 14:57:31
Not sure what value that would add, since this fun
| |
| 291 module_->GetFunctionSignature(operand.index)->parameter_count()); | |
| 292 } | 291 } |
| 293 case kExprCallIndirect: { | 292 case kExprCallIndirect: { |
| 294 CallIndirectOperand operand(this, pc); | 293 CallIndirectOperand operand(this, pc); |
| 295 return 1 + static_cast<int>( | 294 return 1 + operand.arity; |
| 296 module_->GetSignature(operand.index)->parameter_count()); | |
| 297 } | 295 } |
| 298 case kExprCallImport: { | 296 case kExprCallImport: { |
| 299 CallImportOperand operand(this, pc); | 297 CallImportOperand operand(this, pc); |
| 300 return static_cast<int>( | 298 return operand.arity; |
| 301 module_->GetImportSignature(operand.index)->parameter_count()); | |
| 302 } | 299 } |
| 303 case kExprReturn: { | 300 case kExprReturn: { |
| 304 return static_cast<int>(sig_->return_count()); | 301 ReturnArityOperand operand(this, pc); |
| 302 return operand.arity; | |
| 305 } | 303 } |
| 306 | 304 |
| 307 #define DECLARE_OPCODE_CASE(name, opcode, sig) \ | 305 #define DECLARE_OPCODE_CASE(name, opcode, sig) \ |
| 308 case kExpr##name: \ | 306 case kExpr##name: \ |
| 309 return kArity_##sig; | 307 return kArity_##sig; |
| 310 | 308 |
| 311 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) | 309 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) |
| 312 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) | 310 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) |
| 313 FOREACH_MISC_MEM_OPCODE(DECLARE_OPCODE_CASE) | 311 FOREACH_MISC_MEM_OPCODE(DECLARE_OPCODE_CASE) |
| 314 FOREACH_SIMPLE_OPCODE(DECLARE_OPCODE_CASE) | 312 FOREACH_SIMPLE_OPCODE(DECLARE_OPCODE_CASE) |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1516 } | 1514 } |
| 1517 if (tree.count > 0) os << ")"; | 1515 if (tree.count > 0) os << ")"; |
| 1518 return os; | 1516 return os; |
| 1519 } | 1517 } |
| 1520 | 1518 |
| 1521 int OpcodeLength(const byte* pc, const byte* end) { | 1519 int OpcodeLength(const byte* pc, const byte* end) { |
| 1522 WasmDecoder decoder(nullptr, nullptr, pc, end); | 1520 WasmDecoder decoder(nullptr, nullptr, pc, end); |
| 1523 return decoder.OpcodeLength(pc); | 1521 return decoder.OpcodeLength(pc); |
| 1524 } | 1522 } |
| 1525 | 1523 |
| 1526 int OpcodeArity(ModuleEnv* module, FunctionSig* sig, const byte* pc, | 1524 int OpcodeArity(const byte* pc, const byte* end) { |
| 1527 const byte* end) { | 1525 WasmDecoder decoder(nullptr, nullptr, pc, end); |
|
ahaas
2016/05/02 14:48:28
Could you make OpcodeArity a static function?
titzer
2016/05/02 14:57:31
The decoder classes are not exposed through the he
ahaas
2016/05/02 15:12:41
What I mean is, I don't see a point why you have t
| |
| 1528 WasmDecoder decoder(module, sig, pc, end); | |
| 1529 return decoder.OpcodeArity(pc); | 1526 return decoder.OpcodeArity(pc); |
| 1530 } | 1527 } |
| 1531 | 1528 |
| 1532 void PrintAst(base::AccountingAllocator* allocator, FunctionBody& body) { | 1529 void PrintAst(base::AccountingAllocator* allocator, FunctionBody& body) { |
| 1533 Zone zone(allocator); | 1530 Zone zone(allocator); |
| 1534 SR_WasmDecoder decoder(&zone, nullptr, body); | 1531 SR_WasmDecoder decoder(&zone, nullptr, body); |
| 1535 | 1532 |
| 1536 OFStream os(stdout); | 1533 OFStream os(stdout); |
| 1537 | 1534 |
| 1538 // Print the function signature. | 1535 // Print the function signature. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1620 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, | 1617 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, |
| 1621 const byte* start, const byte* end) { | 1618 const byte* start, const byte* end) { |
| 1622 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; | 1619 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; |
| 1623 SR_WasmDecoder decoder(zone, nullptr, body); | 1620 SR_WasmDecoder decoder(zone, nullptr, body); |
| 1624 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); | 1621 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); |
| 1625 } | 1622 } |
| 1626 | 1623 |
| 1627 } // namespace wasm | 1624 } // namespace wasm |
| 1628 } // namespace internal | 1625 } // namespace internal |
| 1629 } // namespace v8 | 1626 } // namespace v8 |
| OLD | NEW |