Revision: 14977
Author: [email protected]
Date: Thu Jun 6 06:22:42 2013
Log: Move runtime array constructor functions from builtins.cc to
runtime.cc.
Not only is runtime.cc a better location, but situations arise soon where
we'll
want to make runtime calls to these functions.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/16399007
http://code.google.com/p/v8/source/detail?r=14977
Deleted:
/branches/bleeding_edge/src/builtins-decls.h
Modified:
/branches/bleeding_edge/src/arm/code-stubs-arm.cc
/branches/bleeding_edge/src/builtins.cc
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/mips/code-stubs-mips.cc
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/src/runtime.h
/branches/bleeding_edge/src/x64/code-stubs-x64.cc
/branches/bleeding_edge/test/mjsunit/fuzz-natives-part2.js
=======================================
--- /branches/bleeding_edge/src/builtins-decls.h Wed Jun 5 03:43:18 2013
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following
-// disclaimer in the documentation and/or other materials provided
-// with the distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived
-// from this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#ifndef V8_BUILTINS_DECLS_H_
-#define V8_BUILTINS_DECLS_H_
-
-#include "arguments.h"
-
-namespace v8 {
-namespace internal {
-
-// TODO(mvstanton): move these to runtime.h/.cc
-DECLARE_RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure);
-DECLARE_RUNTIME_FUNCTION(MaybeObject*,
InternalArrayConstructor_StubFailure);
-
-} } // namespace v8::internal
-
-#endif // V8_BUILTINS_DECLS_H_
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Jun 6 04:58:02
2013
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Jun 6 06:22:42
2013
@@ -30,7 +30,6 @@
#if defined(V8_TARGET_ARCH_ARM)
#include "bootstrapper.h"
-#include "builtins-decls.h"
#include "code-stubs.h"
#include "regexp-macro-assembler.h"
#include "stub-cache.h"
@@ -146,7 +145,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(ArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kArrayConstructor)->entry;
}
@@ -168,7 +167,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(InternalArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry;
}
=======================================
--- /branches/bleeding_edge/src/builtins.cc Thu Jun 6 02:26:30 2013
+++ /branches/bleeding_edge/src/builtins.cc Thu Jun 6 06:22:42 2013
@@ -192,106 +192,6 @@
BUILTIN(EmptyFunction) {
return isolate->heap()->undefined_value();
}
-
-
-static MaybeObject* ArrayConstructorStubFailureCommon(
- Isolate* isolate,
- Handle<JSFunction> constructor,
- Handle<Object> type_info,
- Arguments* caller_args) {
- bool holey = false;
- bool can_use_type_feedback = true;
- if (caller_args->length() == 1) {
- Object* argument_one = (*caller_args)[0];
- if (argument_one->IsSmi()) {
- int value = Smi::cast(argument_one)->value();
- if (value < 0 || value >= JSObject::kInitialMaxFastElementArray) {
- // the array is a dictionary in this case.
- can_use_type_feedback = false;
- } else if (value != 0) {
- holey = true;
- }
- } else {
- // Non-smi length argument produces a dictionary
- can_use_type_feedback = false;
- }
- }
-
- JSArray* array;
- MaybeObject* maybe_array;
- if (!type_info.is_null() &&
- *type_info != isolate->heap()->undefined_value() &&
- JSGlobalPropertyCell::cast(*type_info)->value()->IsSmi() &&
- can_use_type_feedback) {
- JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info);
- Smi* smi = Smi::cast(cell->value());
- ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
- if (holey && !IsFastHoleyElementsKind(to_kind)) {
- to_kind = GetHoleyElementsKind(to_kind);
- // Update the allocation site info to reflect the advice alteration.
- cell->set_value(Smi::FromInt(to_kind));
- }
-
- maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
- *constructor, type_info);
- if (!maybe_array->To(&array)) return maybe_array;
- } else {
- maybe_array = isolate->heap()->AllocateJSObject(*constructor);
- if (!maybe_array->To(&array)) return maybe_array;
- // We might need to transition to holey
- ElementsKind kind = constructor->initial_map()->elements_kind();
- if (holey && !IsFastHoleyElementsKind(kind)) {
- kind = GetHoleyElementsKind(kind);
- maybe_array = array->TransitionElementsKind(kind);
- if (maybe_array->IsFailure()) return maybe_array;
- }
- }
-
- maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0,
- DONT_INITIALIZE_ARRAY_ELEMENTS);
- if (maybe_array->IsFailure()) return maybe_array;
- maybe_array = ArrayConstructInitializeElements(array, caller_args);
- if (maybe_array->IsFailure()) return maybe_array;
- return array;
-}
-
-
-RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) {
- // If we get 2 arguments then they are the stub parameters (constructor,
type
- // info). If we get 3, then the first one is a pointer to the arguments
- // passed by the caller.
- Arguments empty_args(0, NULL);
- bool no_caller_args = args.length() == 2;
- ASSERT(no_caller_args || args.length() == 3);
- int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args = no_caller_args
- ? &empty_args
- : reinterpret_cast<Arguments*>(args[0]);
- Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start);
- Handle<Object> type_info = args.at<Object>(parameters_start + 1);
-
- return ArrayConstructorStubFailureCommon(isolate,
- constructor,
- type_info,
- caller_args);
-}
-
-
-RUNTIME_FUNCTION(MaybeObject*, InternalArrayConstructor_StubFailure) {
- Arguments empty_args(0, NULL);
- bool no_caller_args = args.length() == 1;
- ASSERT(no_caller_args || args.length() == 2);
- int parameters_start = no_caller_args ? 0 : 1;
- Arguments* caller_args = no_caller_args
- ? &empty_args
- : reinterpret_cast<Arguments*>(args[0]);
- Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start);
-
- return ArrayConstructorStubFailureCommon(isolate,
- constructor,
- Handle<Object>::null(),
- caller_args);
-}
static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Jun 5 14:02:29
2013
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Jun 6 06:22:42
2013
@@ -30,7 +30,6 @@
#if defined(V8_TARGET_ARCH_IA32)
#include "bootstrapper.h"
-#include "builtins-decls.h"
#include "code-stubs.h"
#include "isolate.h"
#include "jsregexp.h"
@@ -138,7 +137,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(ArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kArrayConstructor)->entry;
}
@@ -160,7 +159,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(InternalArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry;
}
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Wed Jun 5 09:06:38
2013
+++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Jun 6 06:22:42
2013
@@ -30,7 +30,6 @@
#if defined(V8_TARGET_ARCH_MIPS)
#include "bootstrapper.h"
-#include "builtins-decls.h"
#include "code-stubs.h"
#include "codegen.h"
#include "regexp-macro-assembler.h"
@@ -147,7 +146,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(ArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kArrayConstructor)->entry;
}
@@ -169,7 +168,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(InternalArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry;
}
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Jun 5 01:43:25 2013
+++ /branches/bleeding_edge/src/runtime.cc Thu Jun 6 06:22:42 2013
@@ -13439,6 +13439,107 @@
}
return object;
}
+
+
+static MaybeObject* ArrayConstructorCommon(Isolate* isolate,
+ Handle<JSFunction> constructor,
+ Handle<Object> type_info,
+ Arguments* caller_args) {
+ bool holey = false;
+ bool can_use_type_feedback = true;
+ if (caller_args->length() == 1) {
+ Object* argument_one = (*caller_args)[0];
+ if (argument_one->IsSmi()) {
+ int value = Smi::cast(argument_one)->value();
+ if (value < 0 || value >= JSObject::kInitialMaxFastElementArray) {
+ // the array is a dictionary in this case.
+ can_use_type_feedback = false;
+ } else if (value != 0) {
+ holey = true;
+ }
+ } else {
+ // Non-smi length argument produces a dictionary
+ can_use_type_feedback = false;
+ }
+ }
+
+ JSArray* array;
+ MaybeObject* maybe_array;
+ if (!type_info.is_null() &&
+ *type_info != isolate->heap()->undefined_value() &&
+ JSGlobalPropertyCell::cast(*type_info)->value()->IsSmi() &&
+ can_use_type_feedback) {
+ JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info);
+ Smi* smi = Smi::cast(cell->value());
+ ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
+ if (holey && !IsFastHoleyElementsKind(to_kind)) {
+ to_kind = GetHoleyElementsKind(to_kind);
+ // Update the allocation site info to reflect the advice alteration.
+ cell->set_value(Smi::FromInt(to_kind));
+ }
+
+ maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
+ *constructor, type_info);
+ if (!maybe_array->To(&array)) return maybe_array;
+ } else {
+ maybe_array = isolate->heap()->AllocateJSObject(*constructor);
+ if (!maybe_array->To(&array)) return maybe_array;
+ // We might need to transition to holey
+ ElementsKind kind = constructor->initial_map()->elements_kind();
+ if (holey && !IsFastHoleyElementsKind(kind)) {
+ kind = GetHoleyElementsKind(kind);
+ maybe_array = array->TransitionElementsKind(kind);
+ if (maybe_array->IsFailure()) return maybe_array;
+ }
+ }
+
+ maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0,
+ DONT_INITIALIZE_ARRAY_ELEMENTS);
+ if (maybe_array->IsFailure()) return maybe_array;
+ maybe_array = ArrayConstructInitializeElements(array, caller_args);
+ if (maybe_array->IsFailure()) return maybe_array;
+ return array;
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) {
+ HandleScope scope(isolate);
+ // If we get 2 arguments then they are the stub parameters (constructor,
type
+ // info). If we get 3, then the first one is a pointer to the arguments
+ // passed by the caller.
+ Arguments empty_args(0, NULL);
+ bool no_caller_args = args.length() == 2;
+ ASSERT(no_caller_args || args.length() == 3);
+ int parameters_start = no_caller_args ? 0 : 1;
+ Arguments* caller_args = no_caller_args
+ ? &empty_args
+ : reinterpret_cast<Arguments*>(args[0]);
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
+ CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1);
+
+ return ArrayConstructorCommon(isolate,
+ constructor,
+ type_info,
+ caller_args);
+}
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) {
+ HandleScope scope(isolate);
+ Arguments empty_args(0, NULL);
+ bool no_caller_args = args.length() == 1;
+ ASSERT(no_caller_args || args.length() == 2);
+ int parameters_start = no_caller_args ? 0 : 1;
+ Arguments* caller_args = no_caller_args
+ ? &empty_args
+ : reinterpret_cast<Arguments*>(args[0]);
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start);
+
+ return ArrayConstructorCommon(isolate,
+ constructor,
+ Handle<Object>::null(),
+ caller_args);
+}
//
----------------------------------------------------------------------------
=======================================
--- /branches/bleeding_edge/src/runtime.h Tue May 28 02:38:28 2013
+++ /branches/bleeding_edge/src/runtime.h Thu Jun 6 06:22:42 2013
@@ -287,6 +287,8 @@
F(GetArrayKeys, 2, 1) \
F(MoveArrayContents, 2, 1) \
F(EstimateNumberOfElements, 1, 1) \
+ F(ArrayConstructor, -1, 1) \
+ F(InternalArrayConstructor, -1, 1) \
\
/* Getters and Setters */ \
F(LookupAccessor, 3, 1) \
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Jun 5 14:02:29
2013
+++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Thu Jun 6 06:22:42
2013
@@ -30,7 +30,6 @@
#if defined(V8_TARGET_ARCH_X64)
#include "bootstrapper.h"
-#include "builtins-decls.h"
#include "code-stubs.h"
#include "regexp-macro-assembler.h"
#include "stub-cache.h"
@@ -133,7 +132,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(ArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kArrayConstructor)->entry;
}
@@ -155,7 +154,7 @@
descriptor->register_params_ = registers;
descriptor->function_mode_ = JS_FUNCTION_STUB_MODE;
descriptor->deoptimization_handler_ =
- FUNCTION_ADDR(InternalArrayConstructor_StubFailure);
+ Runtime::FunctionForId(Runtime::kInternalArrayConstructor)->entry;
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/fuzz-natives-part2.js Tue Mar 12
11:03:18 2013
+++ /branches/bleeding_edge/test/mjsunit/fuzz-natives-part2.js Thu Jun 6
06:22:42 2013
@@ -162,6 +162,8 @@
"ResolvePossiblyDirectEval": true,
"Log": true,
"DeclareGlobals": true,
+ "ArrayConstructor": true,
+ "InternalArrayConstructor": true,
"PromoteScheduledException": true,
"DeleteHandleScopeExtensions": true,
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.