OLD | NEW |
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 | 4 |
5 #include "vm/kernel_binary_flowgraph.h" | 5 #include "vm/kernel_binary_flowgraph.h" |
6 | 6 |
7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
8 #include "vm/longjump.h" | 8 #include "vm/longjump.h" |
9 #include "vm/object_store.h" | 9 #include "vm/object_store.h" |
10 | 10 |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 721 |
722 ExitScope(builder_->reader_->min_position(), | 722 ExitScope(builder_->reader_->min_position(), |
723 builder_->reader_->max_position()); | 723 builder_->reader_->max_position()); |
724 return; | 724 return; |
725 } | 725 } |
726 case kEmptyStatement: | 726 case kEmptyStatement: |
727 return; | 727 return; |
728 case kAssertStatement: { | 728 case kAssertStatement: { |
729 if (I->asserts()) { | 729 if (I->asserts()) { |
730 VisitExpression(); // Read condition. | 730 VisitExpression(); // Read condition. |
| 731 builder_->ReadPosition(); // read condition start offset. |
| 732 builder_->ReadPosition(); // read condition end offset. |
731 Tag tag = builder_->ReadTag(); // read (first part of) message. | 733 Tag tag = builder_->ReadTag(); // read (first part of) message. |
732 if (tag == kSomething) { | 734 if (tag == kSomething) { |
733 VisitExpression(); // read (rest of) message. | 735 VisitExpression(); // read (rest of) message. |
734 } | 736 } |
735 } else { | 737 } else { |
736 builder_->SkipExpression(); // Read condition. | 738 builder_->SkipExpression(); // Read condition. |
| 739 builder_->ReadPosition(); // read condition start offset. |
| 740 builder_->ReadPosition(); // read condition end offset. |
737 Tag tag = builder_->ReadTag(); // read (first part of) message. | 741 Tag tag = builder_->ReadTag(); // read (first part of) message. |
738 if (tag == kSomething) { | 742 if (tag == kSomething) { |
739 builder_->SkipExpression(); // read (rest of) message. | 743 builder_->SkipExpression(); // read (rest of) message. |
740 } | 744 } |
741 } | 745 } |
742 return; | 746 return; |
743 } | 747 } |
744 case kLabeledStatement: | 748 case kLabeledStatement: |
745 VisitStatement(); // read body. | 749 VisitStatement(); // read body. |
746 return; | 750 return; |
(...skipping 3392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4139 intptr_t list_length = ReadListLength(); // read number of statements. | 4143 intptr_t list_length = ReadListLength(); // read number of statements. |
4140 for (intptr_t i = 0; i < list_length; ++i) { | 4144 for (intptr_t i = 0; i < list_length; ++i) { |
4141 SkipStatement(); // read ith statement. | 4145 SkipStatement(); // read ith statement. |
4142 } | 4146 } |
4143 return; | 4147 return; |
4144 } | 4148 } |
4145 case kEmptyStatement: | 4149 case kEmptyStatement: |
4146 return; | 4150 return; |
4147 case kAssertStatement: { | 4151 case kAssertStatement: { |
4148 SkipExpression(); // Read condition. | 4152 SkipExpression(); // Read condition. |
| 4153 ReadPosition(); // read condition start offset. |
| 4154 ReadPosition(); // read condition end offset. |
4149 Tag tag = ReadTag(); // read (first part of) message. | 4155 Tag tag = ReadTag(); // read (first part of) message. |
4150 if (tag == kSomething) { | 4156 if (tag == kSomething) { |
4151 SkipExpression(); // read (rest of) message. | 4157 SkipExpression(); // read (rest of) message. |
4152 } | 4158 } |
4153 return; | 4159 return; |
4154 } | 4160 } |
4155 case kLabeledStatement: | 4161 case kLabeledStatement: |
4156 SkipStatement(); // read body. | 4162 SkipStatement(); // read body. |
4157 return; | 4163 return; |
4158 case kBreakStatement: | 4164 case kBreakStatement: |
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5897 // | 5903 // |
5898 // The call to `_AssertionError._evaluateAssertion()` will take care of both | 5904 // The call to `_AssertionError._evaluateAssertion()` will take care of both |
5899 // and returns a boolean. | 5905 // and returns a boolean. |
5900 instructions += BuildExpression(); // read condition. | 5906 instructions += BuildExpression(); // read condition. |
5901 instructions += PushArgument(); | 5907 instructions += PushArgument(); |
5902 instructions += EvaluateAssertion(); | 5908 instructions += EvaluateAssertion(); |
5903 instructions += CheckBooleanInCheckedMode(); | 5909 instructions += CheckBooleanInCheckedMode(); |
5904 instructions += Constant(Bool::True()); | 5910 instructions += Constant(Bool::True()); |
5905 instructions += BranchIfEqual(&then, &otherwise, false); | 5911 instructions += BranchIfEqual(&then, &otherwise, false); |
5906 | 5912 |
| 5913 TokenPosition condition_start_offset = |
| 5914 ReadPosition(); // read condition start offset. |
| 5915 TokenPosition condition_end_offset = |
| 5916 ReadPosition(); // read condition end offset. |
| 5917 |
5907 const dart::Class& klass = dart::Class::ZoneHandle( | 5918 const dart::Class& klass = dart::Class::ZoneHandle( |
5908 Z, dart::Library::LookupCoreClass(Symbols::AssertionError())); | 5919 Z, dart::Library::LookupCoreClass(Symbols::AssertionError())); |
5909 ASSERT(!klass.IsNull()); | 5920 ASSERT(!klass.IsNull()); |
5910 const dart::Function& constructor = dart::Function::ZoneHandle( | 5921 const dart::Function& target = dart::Function::ZoneHandle( |
5911 Z, klass.LookupConstructorAllowPrivate( | 5922 Z, klass.LookupStaticFunctionAllowPrivate(Symbols::ThrowNew())); |
5912 H.DartSymbol("_AssertionError._create"))); | 5923 ASSERT(!target.IsNull()); |
5913 ASSERT(!constructor.IsNull()); | |
5914 | 5924 |
5915 const dart::String& url = H.DartString( | 5925 // Build call to _AsertionError._throwNew(start, end, message) |
5916 parsed_function()->function().ToLibNamePrefixedQualifiedCString(), | |
5917 Heap::kOld); | |
5918 | |
5919 // Create instance of _AssertionError | |
5920 Fragment otherwise_fragment(otherwise); | 5926 Fragment otherwise_fragment(otherwise); |
5921 otherwise_fragment += AllocateObject(klass, 0); | 5927 otherwise_fragment += IntConstant(condition_start_offset.Pos()); |
5922 LocalVariable* instance = MakeTemporary(); | 5928 otherwise_fragment += PushArgument(); // start |
5923 | 5929 otherwise_fragment += IntConstant(condition_end_offset.Pos()); |
5924 // Call _AssertionError._create constructor. | 5930 otherwise_fragment += PushArgument(); // end |
5925 otherwise_fragment += LoadLocal(instance); | |
5926 otherwise_fragment += PushArgument(); // this | |
5927 | |
5928 otherwise_fragment += Constant(H.DartString("<no message>", Heap::kOld)); | |
5929 otherwise_fragment += PushArgument(); // failedAssertion | |
5930 | |
5931 otherwise_fragment += Constant(url); | |
5932 otherwise_fragment += PushArgument(); // url | |
5933 | |
5934 otherwise_fragment += IntConstant(0); | |
5935 otherwise_fragment += PushArgument(); // line | |
5936 | |
5937 otherwise_fragment += IntConstant(0); | |
5938 otherwise_fragment += PushArgument(); // column | |
5939 | |
5940 Tag tag = ReadTag(); // read (first part of) message. | 5931 Tag tag = ReadTag(); // read (first part of) message. |
5941 if (tag == kSomething) { | 5932 if (tag == kSomething) { |
5942 otherwise_fragment += BuildExpression(); // read (rest of) message. | 5933 otherwise_fragment += BuildExpression(); // read (rest of) message. |
5943 } else { | 5934 } else { |
5944 otherwise_fragment += Constant(H.DartString("<no message>", Heap::kOld)); | 5935 otherwise_fragment += Constant(Instance::ZoneHandle(Z)); // null. |
5945 } | 5936 } |
5946 otherwise_fragment += PushArgument(); // message | 5937 otherwise_fragment += PushArgument(); // message |
5947 | 5938 |
5948 otherwise_fragment += StaticCall(TokenPosition::kNoSource, constructor, 6); | 5939 otherwise_fragment += StaticCall(TokenPosition::kNoSource, target, 3); |
5949 otherwise_fragment += Drop(); | |
5950 | |
5951 // Throw _AssertionError exception. | |
5952 otherwise_fragment += PushArgument(); | |
5953 otherwise_fragment += ThrowException(TokenPosition::kNoSource); | |
5954 otherwise_fragment += Drop(); | 5940 otherwise_fragment += Drop(); |
5955 | 5941 |
5956 return Fragment(instructions.entry, then); | 5942 return Fragment(instructions.entry, then); |
5957 } | 5943 } |
5958 | 5944 |
5959 Fragment StreamingFlowGraphBuilder::BuildLabeledStatement() { | 5945 Fragment StreamingFlowGraphBuilder::BuildLabeledStatement() { |
5960 // There can be serveral cases: | 5946 // There can be serveral cases: |
5961 // | 5947 // |
5962 // * the body contains a break | 5948 // * the body contains a break |
5963 // * the body doesn't contain a break | 5949 // * the body doesn't contain a break |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7150 metadata_values.SetAt(i, value); | 7136 metadata_values.SetAt(i, value); |
7151 } | 7137 } |
7152 | 7138 |
7153 return metadata_values.raw(); | 7139 return metadata_values.raw(); |
7154 } | 7140 } |
7155 | 7141 |
7156 } // namespace kernel | 7142 } // namespace kernel |
7157 } // namespace dart | 7143 } // namespace dart |
7158 | 7144 |
7159 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7145 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |