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

Side by Side Diff: runtime/vm/kernel_binary.cc

Issue 2778693002: [kernel] Don't use kernel ast nodes as keys (Closed)
Patch Set: Remove reinterpret_cast that dartium-win-ia32-be doesn't like Created 3 years, 8 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 | « runtime/vm/kernel.h ('k') | runtime/vm/kernel_to_il.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 #if !defined(DART_PRECOMPILED_RUNTIME) 4 #if !defined(DART_PRECOMPILED_RUNTIME)
5 5
6 #include "platform/globals.h" 6 #include "platform/globals.h"
7 #include "vm/flags.h" 7 #include "vm/flags.h"
8 #include "vm/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/kernel.h" 9 #include "vm/kernel.h"
10 #include "vm/kernel_to_il.h" 10 #include "vm/kernel_to_il.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 MallocGrowableArray<CanonicalName*> canonical_names_; 321 MallocGrowableArray<CanonicalName*> canonical_names_;
322 BlockStack<VariableDeclaration> scope_; 322 BlockStack<VariableDeclaration> scope_;
323 BlockStack<TypeParameter> type_parameters_; 323 BlockStack<TypeParameter> type_parameters_;
324 BlockStack<SwitchCase> switch_cases_; 324 BlockStack<SwitchCase> switch_cases_;
325 BlockStack<LabeledStatement>* labels_; 325 BlockStack<LabeledStatement>* labels_;
326 }; 326 };
327 327
328 328
329 class Reader { 329 class Reader {
330 public: 330 public:
331 Reader(const uint8_t* buffer, int64_t size) 331 Reader(const uint8_t* buffer, intptr_t size)
332 : buffer_(buffer), size_(size), offset_(0) {} 332 : buffer_(buffer), size_(size), offset_(0) {}
333 333
334 uint32_t ReadUInt32() { 334 uint32_t ReadUInt32() {
335 ASSERT(offset_ + 4 <= size_); 335 ASSERT(offset_ + 4 <= size_);
336 336
337 uint32_t value = (buffer_[offset_ + 0] << 24) | 337 uint32_t value = (buffer_[offset_ + 0] << 24) |
338 (buffer_[offset_ + 1] << 16) | 338 (buffer_[offset_ + 1] << 16) |
339 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0); 339 (buffer_[offset_ + 2] << 8) | (buffer_[offset_ + 3] << 0);
340 offset_ += 4; 340 offset_ += 4;
341 return value; 341 return value;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 ASSERT(offset_ + count <= size_); 437 ASSERT(offset_ + count <= size_);
438 const uint8_t* old = buffer_ + offset_; 438 const uint8_t* old = buffer_ + offset_;
439 offset_ += count; 439 offset_ += count;
440 return old; 440 return old;
441 } 441 }
442 442
443 void EnsureEnd() { 443 void EnsureEnd() {
444 if (offset_ != size_) { 444 if (offset_ != size_) {
445 FATAL2( 445 FATAL2(
446 "Reading Kernel file: Expected to be at EOF " 446 "Reading Kernel file: Expected to be at EOF "
447 "(offset: %" Pd64 ", size: %" Pd64 ")", 447 "(offset: %" Pd ", size: %" Pd ")",
448 offset_, size_); 448 offset_, size_);
449 } 449 }
450 } 450 }
451 451
452 void DumpOffset(const char* str) { 452 void DumpOffset(const char* str) {
453 OS::PrintErr("@%" Pd64 " %s\n", offset_, str); 453 OS::PrintErr("@%" Pd " %s\n", offset_, str);
454 } 454 }
455 455
456 // The largest position read yet (since last reset). 456 // The largest position read yet (since last reset).
457 // This is automatically updated when calling ReadPosition, 457 // This is automatically updated when calling ReadPosition,
458 // but can be overwritten (e.g. via the PositionScope class). 458 // but can be overwritten (e.g. via the PositionScope class).
459 TokenPosition max_position() { return max_position_; } 459 TokenPosition max_position() { return max_position_; }
460 // The smallest position read yet (since last reset). 460 // The smallest position read yet (since last reset).
461 // This is automatically updated when calling ReadPosition, 461 // This is automatically updated when calling ReadPosition,
462 // but can be overwritten (e.g. via the PositionScope class). 462 // but can be overwritten (e.g. via the PositionScope class).
463 TokenPosition min_position() { return min_position_; } 463 TokenPosition min_position() { return min_position_; }
(...skipping 30 matching lines...) Expand all
494 return name; 494 return name;
495 } 495 }
496 496
497 CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) { 497 CanonicalName* ReadDefiningCanonicalNameReference(LinkedNode* node_to_link) {
498 CanonicalName* name = ReadCanonicalNameReference(); 498 CanonicalName* name = ReadCanonicalNameReference();
499 ASSERT(name != NULL); 499 ASSERT(name != NULL);
500 name->BindTo(node_to_link); 500 name->BindTo(node_to_link);
501 return name; 501 return name;
502 } 502 }
503 503
504 intptr_t offset() { return offset_; }
505
504 private: 506 private:
505 const uint8_t* buffer_; 507 const uint8_t* buffer_;
506 int64_t size_; 508 intptr_t size_;
507 int64_t offset_; 509 intptr_t offset_;
508 ReaderHelper builder_; 510 ReaderHelper builder_;
509 TokenPosition max_position_; 511 TokenPosition max_position_;
510 TokenPosition min_position_; 512 TokenPosition min_position_;
511 intptr_t current_script_id_; 513 intptr_t current_script_id_;
512 514
513 friend class PositionScope; 515 friend class PositionScope;
514 }; 516 };
515 517
516 518
517 // A helper class that resets the readers min and max positions both upon 519 // A helper class that resets the readers min and max positions both upon
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 TRACE_READ_OFFSET(); 631 TRACE_READ_OFFSET();
630 return String::ReadFromImpl(reader); 632 return String::ReadFromImpl(reader);
631 } 633 }
632 }; 634 };
633 635
634 636
635 class VariableDeclarationImpl { 637 class VariableDeclarationImpl {
636 public: 638 public:
637 static VariableDeclaration* ReadFrom(Reader* reader) { 639 static VariableDeclaration* ReadFrom(Reader* reader) {
638 TRACE_READ_OFFSET(); 640 TRACE_READ_OFFSET();
639 return VariableDeclaration::ReadFromImpl(reader); 641 return VariableDeclaration::ReadFromImpl(reader, false);
640 } 642 }
641 }; 643 };
642 644
643 645
644 String* String::ReadFrom(Reader* reader) { 646 String* String::ReadFrom(Reader* reader) {
645 TRACE_READ_OFFSET(); 647 TRACE_READ_OFFSET();
646 return Reference::ReadStringFrom(reader); 648 return Reference::ReadStringFrom(reader);
647 } 649 }
648 650
649 651
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 798
797 799
798 String* Reference::ReadStringFrom(Reader* reader) { 800 String* Reference::ReadStringFrom(Reader* reader) {
799 int index = reader->ReadUInt(); 801 int index = reader->ReadUInt();
800 return reader->helper()->program()->string_table().strings()[index]; 802 return reader->helper()->program()->string_table().strings()[index];
801 } 803 }
802 804
803 805
804 Field* Field::ReadFrom(Reader* reader) { 806 Field* Field::ReadFrom(Reader* reader) {
805 TRACE_READ_OFFSET(); 807 TRACE_READ_OFFSET();
808 kernel_offset_ = reader->offset(); // Notice the ReadTag() below.
806 Tag tag = reader->ReadTag(); 809 Tag tag = reader->ReadTag();
807 ASSERT(tag == kField); 810 ASSERT(tag == kField);
808 811
809 reader->ReadDefiningCanonicalNameReference(this); 812 reader->ReadDefiningCanonicalNameReference(this);
810 position_ = reader->ReadPosition(false); 813 position_ = reader->ReadPosition(false);
811 end_position_ = reader->ReadPosition(false); 814 end_position_ = reader->ReadPosition(false);
812 flags_ = reader->ReadFlags(); 815 flags_ = reader->ReadFlags();
813 name_ = Name::ReadFrom(reader); 816 name_ = Name::ReadFrom(reader);
814 source_uri_index_ = reader->ReadUInt(); 817 source_uri_index_ = reader->ReadUInt();
815 reader->set_current_script_id(source_uri_index_); 818 reader->set_current_script_id(source_uri_index_);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 RedirectingInitializer* init = new RedirectingInitializer(); 915 RedirectingInitializer* init = new RedirectingInitializer();
913 init->target_reference_ = Reference::ReadMemberFrom(reader); 916 init->target_reference_ = Reference::ReadMemberFrom(reader);
914 init->arguments_ = Arguments::ReadFrom(reader); 917 init->arguments_ = Arguments::ReadFrom(reader);
915 return init; 918 return init;
916 } 919 }
917 920
918 921
919 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) { 922 LocalInitializer* LocalInitializer::ReadFromImpl(Reader* reader) {
920 TRACE_READ_OFFSET(); 923 TRACE_READ_OFFSET();
921 LocalInitializer* init = new LocalInitializer(); 924 LocalInitializer* init = new LocalInitializer();
922 init->variable_ = VariableDeclaration::ReadFromImpl(reader); 925 init->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
923 return init; 926 return init;
924 } 927 }
925 928
926 929
927 Expression* Expression::ReadFrom(Reader* reader) { 930 Expression* Expression::ReadFrom(Reader* reader) {
928 TRACE_READ_OFFSET(); 931 TRACE_READ_OFFSET();
929 uint8_t payload = 0; 932 uint8_t payload = 0;
930 Tag tag = reader->ReadTag(&payload); 933 Tag tag = reader->ReadTag(&payload);
931 switch (tag) { 934 switch (tag) {
932 case kInvalidExpression: 935 case kInvalidExpression:
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 AwaitExpression* await = new AwaitExpression(); 1383 AwaitExpression* await = new AwaitExpression();
1381 await->operand_ = Expression::ReadFrom(reader); 1384 await->operand_ = Expression::ReadFrom(reader);
1382 return await; 1385 return await;
1383 } 1386 }
1384 1387
1385 1388
1386 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) { 1389 FunctionExpression* FunctionExpression::ReadFrom(Reader* reader) {
1387 TRACE_READ_OFFSET(); 1390 TRACE_READ_OFFSET();
1388 VariableScope<ReaderHelper> parameters(reader->helper()); 1391 VariableScope<ReaderHelper> parameters(reader->helper());
1389 FunctionExpression* expr = new FunctionExpression(); 1392 FunctionExpression* expr = new FunctionExpression();
1393 expr->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1390 expr->function_ = FunctionNode::ReadFrom(reader); 1394 expr->function_ = FunctionNode::ReadFrom(reader);
1391 return expr; 1395 return expr;
1392 } 1396 }
1393 1397
1394 1398
1395 Let* Let::ReadFrom(Reader* reader) { 1399 Let* Let::ReadFrom(Reader* reader) {
1396 TRACE_READ_OFFSET(); 1400 TRACE_READ_OFFSET();
1397 VariableScope<ReaderHelper> vars(reader->helper()); 1401 VariableScope<ReaderHelper> vars(reader->helper());
1398 PositionScope scope(reader); 1402 PositionScope scope(reader);
1399 1403
1400 Let* let = new Let(); 1404 Let* let = new Let();
1401 let->variable_ = VariableDeclaration::ReadFromImpl(reader); 1405 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1406 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1402 let->body_ = Expression::ReadFrom(reader); 1407 let->body_ = Expression::ReadFrom(reader);
1403 let->position_ = reader->min_position(); 1408 let->position_ = reader->min_position();
1404 let->end_position_ = reader->max_position(); 1409 let->end_position_ = reader->max_position();
1405 1410
1406 return let; 1411 return let;
1407 } 1412 }
1408 1413
1409 1414
1410 Statement* Statement::ReadFrom(Reader* reader) { 1415 Statement* Statement::ReadFrom(Reader* reader) {
1411 TRACE_READ_OFFSET(); 1416 TRACE_READ_OFFSET();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 return IfStatement::ReadFrom(reader); 1448 return IfStatement::ReadFrom(reader);
1444 case kReturnStatement: 1449 case kReturnStatement:
1445 return ReturnStatement::ReadFrom(reader); 1450 return ReturnStatement::ReadFrom(reader);
1446 case kTryCatch: 1451 case kTryCatch:
1447 return TryCatch::ReadFrom(reader); 1452 return TryCatch::ReadFrom(reader);
1448 case kTryFinally: 1453 case kTryFinally:
1449 return TryFinally::ReadFrom(reader); 1454 return TryFinally::ReadFrom(reader);
1450 case kYieldStatement: 1455 case kYieldStatement:
1451 return YieldStatement::ReadFrom(reader); 1456 return YieldStatement::ReadFrom(reader);
1452 case kVariableDeclaration: 1457 case kVariableDeclaration:
1453 return VariableDeclaration::ReadFromImpl(reader); 1458 return VariableDeclaration::ReadFromImpl(reader, true);
1454 case kFunctionDeclaration: 1459 case kFunctionDeclaration:
1455 return FunctionDeclaration::ReadFrom(reader); 1460 return FunctionDeclaration::ReadFrom(reader);
1456 default: 1461 default:
1457 UNREACHABLE(); 1462 UNREACHABLE();
1458 } 1463 }
1459 return NULL; 1464 return NULL;
1460 } 1465 }
1461 1466
1462 1467
1463 InvalidStatement* InvalidStatement::ReadFrom(Reader* reader) { 1468 InvalidStatement* InvalidStatement::ReadFrom(Reader* reader) {
1464 TRACE_READ_OFFSET(); 1469 TRACE_READ_OFFSET();
1465 return new InvalidStatement(); 1470 return new InvalidStatement();
1466 } 1471 }
1467 1472
1468 1473
1469 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) { 1474 ExpressionStatement* ExpressionStatement::ReadFrom(Reader* reader) {
1470 TRACE_READ_OFFSET(); 1475 TRACE_READ_OFFSET();
1471 return new ExpressionStatement(Expression::ReadFrom(reader)); 1476 return new ExpressionStatement(Expression::ReadFrom(reader));
1472 } 1477 }
1473 1478
1474 1479
1475 Block* Block::ReadFromImpl(Reader* reader) { 1480 Block* Block::ReadFromImpl(Reader* reader) {
1476 TRACE_READ_OFFSET(); 1481 TRACE_READ_OFFSET();
1477 PositionScope scope(reader); 1482 PositionScope scope(reader);
1478 1483
1479 VariableScope<ReaderHelper> vars(reader->helper()); 1484 VariableScope<ReaderHelper> vars(reader->helper());
1480 Block* block = new Block(); 1485 Block* block = new Block();
1486 block->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1481 block->statements().ReadFromStatic<Statement>(reader); 1487 block->statements().ReadFromStatic<Statement>(reader);
1482 block->position_ = reader->min_position(); 1488 block->position_ = reader->min_position();
1483 block->end_position_ = reader->max_position(); 1489 block->end_position_ = reader->max_position();
1484 1490
1485 return block; 1491 return block;
1486 } 1492 }
1487 1493
1488 1494
1489 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) { 1495 EmptyStatement* EmptyStatement::ReadFrom(Reader* reader) {
1490 TRACE_READ_OFFSET(); 1496 TRACE_READ_OFFSET();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 return dostmt; 1543 return dostmt;
1538 } 1544 }
1539 1545
1540 1546
1541 ForStatement* ForStatement::ReadFrom(Reader* reader) { 1547 ForStatement* ForStatement::ReadFrom(Reader* reader) {
1542 TRACE_READ_OFFSET(); 1548 TRACE_READ_OFFSET();
1543 VariableScope<ReaderHelper> vars(reader->helper()); 1549 VariableScope<ReaderHelper> vars(reader->helper());
1544 PositionScope scope(reader); 1550 PositionScope scope(reader);
1545 1551
1546 ForStatement* forstmt = new ForStatement(); 1552 ForStatement* forstmt = new ForStatement();
1553 forstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1547 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader); 1554 forstmt->variables_.ReadFromStatic<VariableDeclarationImpl>(reader);
1548 forstmt->condition_ = reader->ReadOptional<Expression>(); 1555 forstmt->condition_ = reader->ReadOptional<Expression>();
1549 forstmt->updates_.ReadFromStatic<Expression>(reader); 1556 forstmt->updates_.ReadFromStatic<Expression>(reader);
1550 forstmt->body_ = Statement::ReadFrom(reader); 1557 forstmt->body_ = Statement::ReadFrom(reader);
1551 forstmt->end_position_ = reader->max_position(); 1558 forstmt->end_position_ = reader->max_position();
1552 forstmt->position_ = reader->min_position(); 1559 forstmt->position_ = reader->min_position();
1553 1560
1554 return forstmt; 1561 return forstmt;
1555 } 1562 }
1556 1563
1557 1564
1558 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) { 1565 ForInStatement* ForInStatement::ReadFrom(Reader* reader, bool is_async) {
1559 TRACE_READ_OFFSET(); 1566 TRACE_READ_OFFSET();
1560 VariableScope<ReaderHelper> vars(reader->helper()); 1567 VariableScope<ReaderHelper> vars(reader->helper());
1561 PositionScope scope(reader); 1568 PositionScope scope(reader);
1562 1569
1563 ForInStatement* forinstmt = new ForInStatement(); 1570 ForInStatement* forinstmt = new ForInStatement();
1571 forinstmt->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1564 forinstmt->is_async_ = is_async; 1572 forinstmt->is_async_ = is_async;
1565 forinstmt->position_ = reader->ReadPosition(); 1573 forinstmt->position_ = reader->ReadPosition();
1566 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader); 1574 forinstmt->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1567 forinstmt->iterable_ = Expression::ReadFrom(reader); 1575 forinstmt->iterable_ = Expression::ReadFrom(reader);
1568 forinstmt->body_ = Statement::ReadFrom(reader); 1576 forinstmt->body_ = Statement::ReadFrom(reader);
1569 forinstmt->end_position_ = reader->max_position(); 1577 forinstmt->end_position_ = reader->max_position();
1570 if (!forinstmt->position_.IsReal()) { 1578 if (!forinstmt->position_.IsReal()) {
1571 forinstmt->position_ = reader->min_position(); 1579 forinstmt->position_ = reader->min_position();
1572 } 1580 }
1573 forinstmt->variable_->set_end_position(forinstmt->position_); 1581 forinstmt->variable_->set_end_position(forinstmt->position_);
1574 1582
1575 return forinstmt; 1583 return forinstmt;
1576 } 1584 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 return tc; 1656 return tc;
1649 } 1657 }
1650 1658
1651 1659
1652 Catch* Catch::ReadFrom(Reader* reader) { 1660 Catch* Catch::ReadFrom(Reader* reader) {
1653 TRACE_READ_OFFSET(); 1661 TRACE_READ_OFFSET();
1654 VariableScope<ReaderHelper> vars(reader->helper()); 1662 VariableScope<ReaderHelper> vars(reader->helper());
1655 PositionScope scope(reader); 1663 PositionScope scope(reader);
1656 1664
1657 Catch* c = new Catch(); 1665 Catch* c = new Catch();
1666 c->kernel_offset_ = reader->offset(); // Catch has no tag.
1658 c->guard_ = DartType::ReadFrom(reader); 1667 c->guard_ = DartType::ReadFrom(reader);
1659 c->exception_ = 1668 c->exception_ =
1660 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 1669 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
1661 c->stack_trace_ = 1670 c->stack_trace_ =
1662 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>(); 1671 reader->ReadOptional<VariableDeclaration, VariableDeclarationImpl>();
1663 c->body_ = Statement::ReadFrom(reader); 1672 c->body_ = Statement::ReadFrom(reader);
1664 c->end_position_ = reader->max_position(); 1673 c->end_position_ = reader->max_position();
1665 c->position_ = reader->min_position(); 1674 c->position_ = reader->min_position();
1666 1675
1667 return c; 1676 return c;
(...skipping 17 matching lines...) Expand all
1685 stmt->flags_ = reader->ReadByte(); 1694 stmt->flags_ = reader->ReadByte();
1686 stmt->expression_ = Expression::ReadFrom(reader); 1695 stmt->expression_ = Expression::ReadFrom(reader);
1687 return stmt; 1696 return stmt;
1688 } 1697 }
1689 1698
1690 1699
1691 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) { 1700 VariableDeclaration* VariableDeclaration::ReadFrom(Reader* reader) {
1692 TRACE_READ_OFFSET(); 1701 TRACE_READ_OFFSET();
1693 Tag tag = reader->ReadTag(); 1702 Tag tag = reader->ReadTag();
1694 ASSERT(tag == kVariableDeclaration); 1703 ASSERT(tag == kVariableDeclaration);
1695 return VariableDeclaration::ReadFromImpl(reader); 1704 return VariableDeclaration::ReadFromImpl(reader, true);
1696 } 1705 }
1697 1706
1698 1707
1699 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader) { 1708 VariableDeclaration* VariableDeclaration::ReadFromImpl(Reader* reader,
1709 bool read_tag) {
1700 TRACE_READ_OFFSET(); 1710 TRACE_READ_OFFSET();
1701 PositionScope scope(reader); 1711 PositionScope scope(reader);
1702 1712
1703 VariableDeclaration* decl = new VariableDeclaration(); 1713 VariableDeclaration* decl = new VariableDeclaration();
1714 // -1 or -0 depending on whether there's a tag or not.
1715 decl->kernel_offset_ = reader->offset() - (read_tag ? 1 : 0);
1704 decl->position_ = reader->ReadPosition(); 1716 decl->position_ = reader->ReadPosition();
1705 decl->equals_position_ = reader->ReadPosition(); 1717 decl->equals_position_ = reader->ReadPosition();
1706 decl->flags_ = reader->ReadFlags(); 1718 decl->flags_ = reader->ReadFlags();
1707 decl->name_ = Reference::ReadStringFrom(reader); 1719 decl->name_ = Reference::ReadStringFrom(reader);
1708 decl->type_ = DartType::ReadFrom(reader); 1720 decl->type_ = DartType::ReadFrom(reader);
1709 decl->initializer_ = reader->ReadOptional<Expression>(); 1721 decl->initializer_ = reader->ReadOptional<Expression>();
1710 1722
1711 // Go to next token position so it ends *after* the last potentially 1723 // Go to next token position so it ends *after* the last potentially
1712 // debuggable position in the initializer. 1724 // debuggable position in the initializer.
1713 TokenPosition position = reader->max_position(); 1725 TokenPosition position = reader->max_position();
1714 if (position.IsReal()) position.Next(); 1726 if (position.IsReal()) position.Next();
1715 decl->end_position_ = position; 1727 decl->end_position_ = position;
1716 reader->helper()->variables().Push(decl); 1728 reader->helper()->variables().Push(decl);
1717 1729
1718 return decl; 1730 return decl;
1719 } 1731 }
1720 1732
1721 1733
1722 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) { 1734 FunctionDeclaration* FunctionDeclaration::ReadFrom(Reader* reader) {
1723 TRACE_READ_OFFSET(); 1735 TRACE_READ_OFFSET();
1724 FunctionDeclaration* decl = new FunctionDeclaration(); 1736 FunctionDeclaration* decl = new FunctionDeclaration();
1737 decl->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
1725 decl->position_ = reader->ReadPosition(); 1738 decl->position_ = reader->ReadPosition();
1726 decl->variable_ = VariableDeclaration::ReadFromImpl(reader); 1739 decl->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
1727 VariableScope<ReaderHelper> parameters(reader->helper()); 1740 VariableScope<ReaderHelper> parameters(reader->helper());
1728 decl->function_ = FunctionNode::ReadFrom(reader); 1741 decl->function_ = FunctionNode::ReadFrom(reader);
1729 return decl; 1742 return decl;
1730 } 1743 }
1731 1744
1732 1745
1733 Name* Name::ReadFrom(Reader* reader) { 1746 Name* Name::ReadFrom(Reader* reader) {
1734 String* string = Reference::ReadStringFrom(reader); 1747 String* string = Reference::ReadStringFrom(reader);
1735 if (string->size() >= 1 && string->buffer()[0] == '_') { 1748 if (string->size() >= 1 && string->buffer()[0] == '_') {
1736 CanonicalName* library_reference = reader->ReadCanonicalNameReference(); 1749 CanonicalName* library_reference = reader->ReadCanonicalNameReference();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 1901
1889 return program; 1902 return program;
1890 } 1903 }
1891 1904
1892 1905
1893 FunctionNode* FunctionNode::ReadFrom(Reader* reader) { 1906 FunctionNode* FunctionNode::ReadFrom(Reader* reader) {
1894 TRACE_READ_OFFSET(); 1907 TRACE_READ_OFFSET();
1895 TypeParameterScope<ReaderHelper> scope(reader->helper()); 1908 TypeParameterScope<ReaderHelper> scope(reader->helper());
1896 1909
1897 FunctionNode* function = new FunctionNode(); 1910 FunctionNode* function = new FunctionNode();
1911 function->kernel_offset_ = reader->offset(); // FunctionNode has no tag.
1898 function->position_ = reader->ReadPosition(); 1912 function->position_ = reader->ReadPosition();
1899 function->end_position_ = reader->ReadPosition(); 1913 function->end_position_ = reader->ReadPosition();
1900 function->async_marker_ = 1914 function->async_marker_ =
1901 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); 1915 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte());
1902 function->dart_async_marker_ = 1916 function->dart_async_marker_ =
1903 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte()); 1917 static_cast<FunctionNode::AsyncMarker>(reader->ReadByte());
1904 function->type_parameters().ReadFrom(reader); 1918 function->type_parameters().ReadFrom(reader);
1905 function->required_parameter_count_ = reader->ReadUInt(); 1919 function->required_parameter_count_ = reader->ReadUInt();
1906 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>( 1920 function->positional_parameters().ReadFromStatic<VariableDeclarationImpl>(
1907 reader); 1921 reader);
(...skipping 21 matching lines...) Expand all
1929 1943
1930 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1944 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1931 intptr_t buffer_length) { 1945 intptr_t buffer_length) {
1932 kernel::Reader reader(buffer, buffer_length); 1946 kernel::Reader reader(buffer, buffer_length);
1933 return kernel::Program::ReadFrom(&reader); 1947 return kernel::Program::ReadFrom(&reader);
1934 } 1948 }
1935 1949
1936 1950
1937 } // namespace dart 1951 } // namespace dart
1938 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1952 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel.h ('k') | runtime/vm/kernel_to_il.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698