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

Unified Diff: src/runtime.cc

Issue 13071006: Codify the assumption that %GetArrayKeys can return only a single interval starting at zero (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Return a single number for an interval Created 7 years, 9 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 | « src/array.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 373fab924473be686d89a747a7102d773b768e4b..4140f94c01cecfd601b86dfc6630a305cfc04dd7 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -9695,20 +9695,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) {
}
-static Handle<Object> NewSingleInterval(Isolate* isolate, uint32_t length) {
- Handle<FixedArray> single_interval = isolate->factory()->NewFixedArray(2);
- // -1 means start of array.
- single_interval->set(0, Smi::FromInt(-1));
- Handle<Object> number = isolate->factory()->NewNumberFromUint(length);
- single_interval->set(1, *number);
- return isolate->factory()->NewJSArrayWithElements(single_interval);
-}
-
-
// Returns an array that tells you where in the [0, length) interval an array
-// might have elements. Can either return keys (positive integers) or
-// intervals (pair of a negative integer (-start-1) followed by a
-// positive (length)) or undefined values.
+// might have elements. Can either return an array of keys (positive integers
+// or undefined) or a number representing the positive length of an interval
+// starting at index 0.
// Intervals can span over some keys that are not in the object.
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
HandleScope scope(isolate);
@@ -9723,7 +9713,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) {
// Bail out if we find a proxy or interceptor, likely not worth
// collecting keys in that case.
- return *NewSingleInterval(isolate, length);
+ return *isolate->factory()->NewNumberFromUint(length);
}
Handle<JSObject> current = Handle<JSObject>::cast(p);
Handle<FixedArray> current_keys =
@@ -9743,7 +9733,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) {
ASSERT(array->HasFastSmiOrObjectElements() ||
array->HasFastDoubleElements());
uint32_t actual_length = static_cast<uint32_t>(array->elements()->length());
- return *NewSingleInterval(isolate, Min(actual_length, length));
+ return *isolate->factory()->NewNumberFromUint(Min(actual_length, length));
}
}
« no previous file with comments | « src/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698