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

Unified Diff: src/builtins.cc

Issue 1436813002: Fix Array.prototype.slice with arguments object with negative length. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | test/mjsunit/regress/regress-arguments-slice.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 7695ccc753f731932de907b74bced1951eace638..e4ceec99be4f17a12d42cb3a6614d0662c2e58ea 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -197,16 +197,12 @@ inline bool ClampedToInteger(Object* object, int* out) {
inline bool GetSloppyArgumentsLength(Isolate* isolate, Handle<JSObject> object,
int* out) {
- Map* arguments_map =
- isolate->context()->native_context()->sloppy_arguments_map();
- if (object->map() != arguments_map || !object->HasFastElements()) {
- return false;
- }
+ Map* arguments_map = isolate->native_context()->sloppy_arguments_map();
+ if (object->map() != arguments_map) return false;
+ DCHECK(object->HasFastElements());
Object* len_obj = object->InObjectPropertyAt(Heap::kArgumentsLengthIndex);
- if (!len_obj->IsSmi()) {
- return false;
- }
- *out = Smi::cast(len_obj)->value();
+ if (!len_obj->IsSmi()) return false;
+ *out = Max(0, Smi::cast(len_obj)->value());
return *out <= object->elements()->length();
}
@@ -993,11 +989,11 @@ bool IterateElements(Isolate* isolate, Handle<JSObject> receiver,
uint32_t length = 0;
if (receiver->IsJSArray()) {
- Handle<JSArray> array(Handle<JSArray>::cast(receiver));
+ Handle<JSArray> array = Handle<JSArray>::cast(receiver);
length = static_cast<uint32_t>(array->length()->Number());
} else {
Handle<Object> val;
- Handle<Object> key(isolate->heap()->length_string(), isolate);
+ Handle<Object> key = isolate->factory()->length_string();
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, val, Runtime::GetObjectProperty(isolate, receiver, key),
false);
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-arguments-slice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698