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

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

Issue 2985193002: [vm] Add error messages for large literals coming from kernel (Closed)
Patch Set: 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
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_reader.h" 5 #include "vm/kernel_reader.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/kernel_binary.h" 10 #include "vm/kernel_binary.h"
(...skipping 20 matching lines...) Expand all
31 : translation_helper_(*helper), 31 : translation_helper_(*helper),
32 zone_(translation_helper_.zone()), 32 zone_(translation_helper_.zone()),
33 simple_value_(NULL), 33 simple_value_(NULL),
34 builder_(builder) {} 34 builder_(builder) {}
35 35
36 bool IsSimple(intptr_t kernel_offset) { 36 bool IsSimple(intptr_t kernel_offset) {
37 AlternativeReadingScope alt(builder_->reader_, kernel_offset); 37 AlternativeReadingScope alt(builder_->reader_, kernel_offset);
38 uint8_t payload = 0; 38 uint8_t payload = 0;
39 Tag tag = builder_->ReadTag(&payload); // read tag. 39 Tag tag = builder_->ReadTag(&payload); // read tag.
40 switch (tag) { 40 switch (tag) {
41 case kBigIntLiteral: 41 case kBigIntLiteral: {
42 simple_value_ = &Integer::ZoneHandle( 42 const dart::String& literal_str =
43 Z, Integer::New( 43 H.DartString(builder_->ReadStringReference(),
44 H.DartString(builder_->ReadStringReference(), 44 Heap::kOld); // read index into string table.
45 Heap::kOld))); // read index into string table. 45 simple_value_ = &Integer::ZoneHandle(Z, Integer::New(literal_str));
46 if (simple_value_->IsNull()) {
47 H.ReportError("Integer literal %s is out of range",
48 literal_str.ToCString());
49 }
46 *simple_value_ = H.Canonicalize(*simple_value_); 50 *simple_value_ = H.Canonicalize(*simple_value_);
47 return true; 51 return true;
52 }
48 case kStringLiteral: 53 case kStringLiteral:
49 simple_value_ = &H.DartSymbol( 54 simple_value_ = &H.DartSymbol(
50 builder_->ReadStringReference()); // read index into string table. 55 builder_->ReadStringReference()); // read index into string table.
51 return true; 56 return true;
52 case kSpecialIntLiteral: 57 case kSpecialIntLiteral:
53 simple_value_ = 58 simple_value_ =
54 &Integer::ZoneHandle(Z, Integer::New(static_cast<int32_t>(payload) - 59 &Integer::ZoneHandle(Z, Integer::New(static_cast<int32_t>(payload) -
55 SpecializedIntLiteralBias, 60 SpecializedIntLiteralBias,
56 Heap::kOld)); 61 Heap::kOld));
57 *simple_value_ = H.Canonicalize(*simple_value_); 62 *simple_value_ = H.Canonicalize(*simple_value_);
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type())); 932 initializer_fun.set_result_type(AbstractType::Handle(zone, field.type()));
928 initializer_fun.set_is_debuggable(false); 933 initializer_fun.set_is_debuggable(false);
929 initializer_fun.set_is_reflectable(false); 934 initializer_fun.set_is_reflectable(false);
930 initializer_fun.set_is_inlinable(false); 935 initializer_fun.set_is_inlinable(false);
931 return new (zone) ParsedFunction(thread, initializer_fun); 936 return new (zone) ParsedFunction(thread, initializer_fun);
932 } 937 }
933 938
934 } // namespace kernel 939 } // namespace kernel
935 } // namespace dart 940 } // namespace dart
936 #endif // !defined(DART_PRECOMPILED_RUNTIME) 941 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« runtime/vm/kernel_binary_flowgraph.cc ('K') | « runtime/vm/kernel_binary_flowgraph.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698