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

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

Issue 2985193002: [vm] Add error messages for large literals coming from kernel (Closed)
Patch Set: Add UNREACHABLE() after ReportError Created 3 years, 4 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 | « no previous file | runtime/vm/kernel_reader.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 (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 2249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 builder_->ReaderOffset(), false)); // read rest of initializer. 2260 builder_->ReaderOffset(), false)); // read rest of initializer.
2261 } 2261 }
2262 2262
2263 EvaluateExpression(builder_->ReaderOffset(), false); // read body 2263 EvaluateExpression(builder_->ReaderOffset(), false); // read body
2264 } 2264 }
2265 2265
2266 void StreamingConstantEvaluator::EvaluateBigIntLiteral() { 2266 void StreamingConstantEvaluator::EvaluateBigIntLiteral() {
2267 const dart::String& value = 2267 const dart::String& value =
2268 H.DartString(builder_->ReadStringReference()); // read string reference. 2268 H.DartString(builder_->ReadStringReference()); // read string reference.
2269 result_ = Integer::New(value, Heap::kOld); 2269 result_ = Integer::New(value, Heap::kOld);
2270 if (result_.IsNull()) {
2271 H.ReportError("Integer literal %s is out of range", value.ToCString());
2272 UNREACHABLE();
2273 }
2270 result_ = H.Canonicalize(result_); 2274 result_ = H.Canonicalize(result_);
2271 } 2275 }
2272 2276
2273 void StreamingConstantEvaluator::EvaluateStringLiteral() { 2277 void StreamingConstantEvaluator::EvaluateStringLiteral() {
2274 result_ = H.DartSymbol(builder_->ReadStringReference()) 2278 result_ = H.DartSymbol(builder_->ReadStringReference())
2275 .raw(); // read string reference. 2279 .raw(); // read string reference.
2276 } 2280 }
2277 2281
2278 void StreamingConstantEvaluator::EvaluateIntLiteral(uint8_t payload) { 2282 void StreamingConstantEvaluator::EvaluateIntLiteral(uint8_t payload) {
2279 int64_t value = static_cast<int32_t>(payload) - SpecializedIntLiteralBias; 2283 int64_t value = static_cast<int32_t>(payload) - SpecializedIntLiteralBias;
(...skipping 3487 matching lines...) Expand 10 before | Expand all | Expand 10 after
5767 instructions += BuildExpression(); // read body. 5771 instructions += BuildExpression(); // read body.
5768 return instructions; 5772 return instructions;
5769 } 5773 }
5770 5774
5771 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral( 5775 Fragment StreamingFlowGraphBuilder::BuildBigIntLiteral(
5772 TokenPosition* position) { 5776 TokenPosition* position) {
5773 if (position != NULL) *position = TokenPosition::kNoSource; 5777 if (position != NULL) *position = TokenPosition::kNoSource;
5774 5778
5775 const dart::String& value = 5779 const dart::String& value =
5776 H.DartString(ReadStringReference()); // read index into string table. 5780 H.DartString(ReadStringReference()); // read index into string table.
5777 return Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld))); 5781 const Integer& integer =
5782 Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld));
5783 if (integer.IsNull()) {
5784 H.ReportError("Integer literal %s is out of range", value.ToCString());
5785 UNREACHABLE();
5786 }
5787 return Constant(integer);
5778 } 5788 }
5779 5789
5780 Fragment StreamingFlowGraphBuilder::BuildStringLiteral( 5790 Fragment StreamingFlowGraphBuilder::BuildStringLiteral(
5781 TokenPosition* position) { 5791 TokenPosition* position) {
5782 if (position != NULL) *position = TokenPosition::kNoSource; 5792 if (position != NULL) *position = TokenPosition::kNoSource;
5783 5793
5784 return Constant( 5794 return Constant(
5785 H.DartSymbol(ReadStringReference())); // read index into string table. 5795 H.DartSymbol(ReadStringReference())); // read index into string table.
5786 } 5796 }
5787 5797
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
7271 } 7281 }
7272 } 7282 }
7273 7283
7274 return Array::Handle(Array::null()); 7284 return Array::Handle(Array::null());
7275 } 7285 }
7276 7286
7277 } // namespace kernel 7287 } // namespace kernel
7278 } // namespace dart 7288 } // namespace dart
7279 7289
7280 #endif // !defined(DART_PRECOMPILED_RUNTIME) 7290 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/kernel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698