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

Unified Diff: runtime/vm/code_generator.cc

Issue 2149023002: VM: Array bounds checks that don't deoptimize for precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/constant_propagator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
diff --git a/runtime/vm/code_generator.cc b/runtime/vm/code_generator.cc
index 9e7f2329060f823a0e644f99a705e757526af254..ea33dae792c80ff9b61b2a3eb07bd6b6181a1bbc 100644
--- a/runtime/vm/code_generator.cc
+++ b/runtime/vm/code_generator.cc
@@ -91,6 +91,35 @@ DEFINE_RUNTIME_ENTRY(TraceFunctionExit, 1) {
}
+DEFINE_RUNTIME_ENTRY(RangeError, 2) {
+ const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0));
+ const Instance& index = Instance::CheckedHandle(arguments.ArgAt(1));
+ if (!length.IsInteger()) {
+ // Throw: new ArgumentError.value(length, "length", "is not an integer");
+ const Array& args = Array::Handle(Array::New(3));
+ args.SetAt(0, length);
+ args.SetAt(1, Symbols::Length());
+ args.SetAt(2, String::Handle(String::New("is not an integer")));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, args);
+ }
+ if (!index.IsInteger()) {
+ // Throw: new ArgumentError.value(index, "index", "is not an integer");
+ const Array& args = Array::Handle(Array::New(3));
+ args.SetAt(0, index);
+ args.SetAt(1, Symbols::Index());
+ args.SetAt(2, String::Handle(String::New("is not an integer")));
+ Exceptions::ThrowByType(Exceptions::kArgumentValue, args);
+ }
+ // Throw: new RangeError.range(index, 0, length, "length");
+ const Array& args = Array::Handle(Array::New(4));
+ args.SetAt(0, index);
+ args.SetAt(1, Integer::Handle(Integer::New(0)));
+ args.SetAt(2, length);
+ args.SetAt(3, Symbols::Length());
+ Exceptions::ThrowByType(Exceptions::kRange, args);
+}
+
+
// Allocation of a fixed length array of given element type.
// This runtime entry is never called for allocating a List of a generic type,
// because a prior run time call instantiates the element type if necessary.
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/constant_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698