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

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

Issue 2792333002: Add Kernel AST nodes for Vector and Closure primitives in VM (Closed)
Patch Set: Remove PositionScopes and static_cast for UInts 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_binary.h ('k') | no next file » | 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 "vm/kernel_binary.h" 6 #include "vm/kernel_binary.h"
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/growable_array.h" 9 #include "vm/growable_array.h"
10 #include "vm/kernel.h" 10 #include "vm/kernel.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 case kMapLiteral: 496 case kMapLiteral:
497 return MapLiteral::ReadFrom(reader, false); 497 return MapLiteral::ReadFrom(reader, false);
498 case kConstMapLiteral: 498 case kConstMapLiteral:
499 return MapLiteral::ReadFrom(reader, true); 499 return MapLiteral::ReadFrom(reader, true);
500 case kAwaitExpression: 500 case kAwaitExpression:
501 return AwaitExpression::ReadFrom(reader); 501 return AwaitExpression::ReadFrom(reader);
502 case kFunctionExpression: 502 case kFunctionExpression:
503 return FunctionExpression::ReadFrom(reader); 503 return FunctionExpression::ReadFrom(reader);
504 case kLet: 504 case kLet:
505 return Let::ReadFrom(reader); 505 return Let::ReadFrom(reader);
506 case kVectorCreation:
507 return VectorCreation::ReadFrom(reader);
508 case kVectorGet:
509 return VectorGet::ReadFrom(reader);
510 case kVectorSet:
511 return VectorSet::ReadFrom(reader);
512 case kVectorCopy:
513 return VectorCopy::ReadFrom(reader);
514 case kClosureCreation:
515 return ClosureCreation::ReadFrom(reader);
506 case kBigIntLiteral: 516 case kBigIntLiteral:
507 return BigintLiteral::ReadFrom(reader); 517 return BigintLiteral::ReadFrom(reader);
508 case kStringLiteral: 518 case kStringLiteral:
509 return StringLiteral::ReadFrom(reader); 519 return StringLiteral::ReadFrom(reader);
510 case kSpecialIntLiteral: 520 case kSpecialIntLiteral:
511 return IntLiteral::ReadFrom(reader, payload); 521 return IntLiteral::ReadFrom(reader, payload);
512 case kNegativeIntLiteral: 522 case kNegativeIntLiteral:
513 return IntLiteral::ReadFrom(reader, true); 523 return IntLiteral::ReadFrom(reader, true);
514 case kPositiveIntLiteral: 524 case kPositiveIntLiteral:
515 return IntLiteral::ReadFrom(reader, false); 525 return IntLiteral::ReadFrom(reader, false);
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte. 960 let->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
951 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false); 961 let->variable_ = VariableDeclaration::ReadFromImpl(reader, false);
952 let->body_ = Expression::ReadFrom(reader); 962 let->body_ = Expression::ReadFrom(reader);
953 let->position_ = reader->min_position(); 963 let->position_ = reader->min_position();
954 let->end_position_ = reader->max_position(); 964 let->end_position_ = reader->max_position();
955 965
956 return let; 966 return let;
957 } 967 }
958 968
959 969
970 VectorCreation* VectorCreation::ReadFrom(Reader* reader) {
971 TRACE_READ_OFFSET();
972
973 VectorCreation* vector_creation = new VectorCreation();
974 vector_creation->kernel_offset_ =
975 reader->offset() - 1; // -1 to include tag byte.
976 vector_creation->value_ = reader->ReadUInt();
977
978 return vector_creation;
979 }
980
981
982 VectorGet* VectorGet::ReadFrom(Reader* reader) {
983 TRACE_READ_OFFSET();
984
985 VectorGet* vector_get = new VectorGet();
986 vector_get->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
987 vector_get->vector_expression_ = Expression::ReadFrom(reader);
988 vector_get->index_ = reader->ReadUInt();
989
990 return vector_get;
991 }
992
993
994 VectorSet* VectorSet::ReadFrom(Reader* reader) {
995 TRACE_READ_OFFSET();
996
997 VectorSet* vector_set = new VectorSet();
998 vector_set->kernel_offset_ = reader->offset() - 1; // -1 to include tag byte.
999 vector_set->vector_expression_ = Expression::ReadFrom(reader);
1000 vector_set->index_ = reader->ReadUInt();
1001 vector_set->value_ = Expression::ReadFrom(reader);
1002
1003 return vector_set;
1004 }
1005
1006
1007 VectorCopy* VectorCopy::ReadFrom(Reader* reader) {
1008 TRACE_READ_OFFSET();
1009
1010 VectorCopy* vector_copy = new VectorCopy();
1011 vector_copy->kernel_offset_ =
1012 reader->offset() - 1; // -1 to include tag byte.
1013 vector_copy->vector_expression_ = Expression::ReadFrom(reader);
1014
1015 return vector_copy;
1016 }
1017
1018
1019 ClosureCreation* ClosureCreation::ReadFrom(Reader* reader) {
1020 TRACE_READ_OFFSET();
1021
1022 ClosureCreation* closure_creation = new ClosureCreation();
1023 closure_creation->kernel_offset_ =
1024 reader->offset() - 1; // to include tag byte.
1025 closure_creation->top_level_function_reference_ =
1026 Reference::ReadMemberFrom(reader);
1027 closure_creation->context_vector_ = Expression::ReadFrom(reader);
1028 closure_creation->function_type_ =
1029 FunctionType::Cast(DartType::ReadFrom(reader));
1030
1031 return closure_creation;
1032 }
1033
1034
960 Statement* Statement::ReadFrom(Reader* reader) { 1035 Statement* Statement::ReadFrom(Reader* reader) {
961 TRACE_READ_OFFSET(); 1036 TRACE_READ_OFFSET();
962 Tag tag = reader->ReadTag(); 1037 Tag tag = reader->ReadTag();
963 switch (tag) { 1038 switch (tag) {
964 case kInvalidStatement: 1039 case kInvalidStatement:
965 return InvalidStatement::ReadFrom(reader); 1040 return InvalidStatement::ReadFrom(reader);
966 case kExpressionStatement: 1041 case kExpressionStatement:
967 return ExpressionStatement::ReadFrom(reader); 1042 return ExpressionStatement::ReadFrom(reader);
968 case kBlock: 1043 case kBlock:
969 return Block::ReadFromImpl(reader); 1044 return Block::ReadFromImpl(reader);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 case kInterfaceType: 1387 case kInterfaceType:
1313 return InterfaceType::ReadFrom(reader); 1388 return InterfaceType::ReadFrom(reader);
1314 case kSimpleInterfaceType: 1389 case kSimpleInterfaceType:
1315 return InterfaceType::ReadFrom(reader, true); 1390 return InterfaceType::ReadFrom(reader, true);
1316 case kFunctionType: 1391 case kFunctionType:
1317 return FunctionType::ReadFrom(reader); 1392 return FunctionType::ReadFrom(reader);
1318 case kSimpleFunctionType: 1393 case kSimpleFunctionType:
1319 return FunctionType::ReadFrom(reader, true); 1394 return FunctionType::ReadFrom(reader, true);
1320 case kTypeParameterType: 1395 case kTypeParameterType:
1321 return TypeParameterType::ReadFrom(reader); 1396 return TypeParameterType::ReadFrom(reader);
1397 case kVectorType:
1398 return VectorType::ReadFrom(reader);
1322 default: 1399 default:
1323 UNREACHABLE(); 1400 UNREACHABLE();
1324 } 1401 }
1325 UNREACHABLE(); 1402 UNREACHABLE();
1326 return NULL; 1403 return NULL;
1327 } 1404 }
1328 1405
1329 1406
1330 InvalidType* InvalidType::ReadFrom(Reader* reader) { 1407 InvalidType* InvalidType::ReadFrom(Reader* reader) {
1331 TRACE_READ_OFFSET(); 1408 TRACE_READ_OFFSET();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 1467
1391 TypeParameterType* TypeParameterType::ReadFrom(Reader* reader) { 1468 TypeParameterType* TypeParameterType::ReadFrom(Reader* reader) {
1392 TRACE_READ_OFFSET(); 1469 TRACE_READ_OFFSET();
1393 TypeParameterType* type = new TypeParameterType(); 1470 TypeParameterType* type = new TypeParameterType();
1394 type->parameter_ = 1471 type->parameter_ =
1395 reader->helper()->type_parameters().Lookup(reader->ReadUInt()); 1472 reader->helper()->type_parameters().Lookup(reader->ReadUInt());
1396 return type; 1473 return type;
1397 } 1474 }
1398 1475
1399 1476
1477 VectorType* VectorType::ReadFrom(Reader* reader) {
1478 TRACE_READ_OFFSET();
1479 VectorType* type = new VectorType();
1480 return type;
1481 }
1482
1483
1400 Program* Program::ReadFrom(Reader* reader) { 1484 Program* Program::ReadFrom(Reader* reader) {
1401 TRACE_READ_OFFSET(); 1485 TRACE_READ_OFFSET();
1402 uint32_t magic = reader->ReadUInt32(); 1486 uint32_t magic = reader->ReadUInt32();
1403 if (magic != kMagicProgramFile) FATAL("Invalid magic identifier"); 1487 if (magic != kMagicProgramFile) FATAL("Invalid magic identifier");
1404 1488
1405 Program* program = new Program(); 1489 Program* program = new Program();
1406 program->canonical_name_root_ = CanonicalName::NewRoot(); 1490 program->canonical_name_root_ = CanonicalName::NewRoot();
1407 reader->helper()->set_program(program); 1491 reader->helper()->set_program(program);
1408 1492
1409 program->string_table_.ReadFrom(reader); 1493 program->string_table_.ReadFrom(reader);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 1563
1480 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer, 1564 kernel::Program* ReadPrecompiledKernelFromBuffer(const uint8_t* buffer,
1481 intptr_t buffer_length) { 1565 intptr_t buffer_length) {
1482 kernel::Reader reader(buffer, buffer_length); 1566 kernel::Reader reader(buffer, buffer_length);
1483 return kernel::Program::ReadFrom(&reader); 1567 return kernel::Program::ReadFrom(&reader);
1484 } 1568 }
1485 1569
1486 1570
1487 } // namespace dart 1571 } // namespace dart
1488 #endif // !defined(DART_PRECOMPILED_RUNTIME) 1572 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_binary.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698