From 19232a1e7a422dd32be6a6da61c4a3d41d71e573 Mon Sep 17 00:00:00 2001 From: "adamk@chromium.org" Date: Wed, 6 Feb 2013 17:35:35 +0000 Subject: [PATCH] Use asserts instead of branches to avoid fast array methods for observed arrays Because observed arrays should always be in dictionary mode, we'll always fall back to the JS version anyway. Review URL: https://codereview.chromium.org/12221033 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13612 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/builtins.cc | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/builtins.cc b/src/builtins.cc index 16e672c16f..188528b6e0 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -525,12 +525,9 @@ BUILTIN(ArrayPush) { } if (!maybe_elms_obj->To(&elms_obj)) return maybe_elms_obj; - if (FLAG_harmony_observation && - JSObject::cast(receiver)->map()->is_observed()) { - return CallJsBuiltin(isolate, "ArrayPush", args); - } - JSArray* array = JSArray::cast(receiver); + ASSERT(!array->map()->is_observed()); + ElementsKind kind = array->GetElementsKind(); if (IsFastSmiOrObjectElementsKind(kind)) { @@ -642,10 +639,7 @@ BUILTIN(ArrayPop) { if (!maybe_elms->To(&elms_obj)) return maybe_elms; JSArray* array = JSArray::cast(receiver); - - if (FLAG_harmony_observation && array->map()->is_observed()) { - return CallJsBuiltin(isolate, "ArrayPop", args); - } + ASSERT(!array->map()->is_observed()); int len = Smi::cast(array->length())->value(); if (len == 0) return heap->undefined_value(); @@ -680,10 +674,7 @@ BUILTIN(ArrayShift) { return CallJsBuiltin(isolate, "ArrayShift", args); } JSArray* array = JSArray::cast(receiver); - - if (FLAG_harmony_observation && array->map()->is_observed()) { - return CallJsBuiltin(isolate, "ArrayShift", args); - } + ASSERT(!array->map()->is_observed()); int len = Smi::cast(array->length())->value(); if (len == 0) return heap->undefined_value(); @@ -734,15 +725,12 @@ BUILTIN(ArrayUnshift) { return CallJsBuiltin(isolate, "ArrayUnshift", args); } JSArray* array = JSArray::cast(receiver); + ASSERT(!array->map()->is_observed()); if (!array->HasFastSmiOrObjectElements()) { return CallJsBuiltin(isolate, "ArrayUnshift", args); } FixedArray* elms = FixedArray::cast(elms_obj); - if (FLAG_harmony_observation && array->map()->is_observed()) { - return CallJsBuiltin(isolate, "ArrayUnshift", args); - } - int len = Smi::cast(array->length())->value(); int to_add = args.length() - 1; int new_length = len + to_add; @@ -938,10 +926,7 @@ BUILTIN(ArraySplice) { return CallJsBuiltin(isolate, "ArraySplice", args); } JSArray* array = JSArray::cast(receiver); - - if (FLAG_harmony_observation && array->map()->is_observed()) { - return CallJsBuiltin(isolate, "ArraySplice", args); - } + ASSERT(!array->map()->is_observed()); int len = Smi::cast(array->length())->value();