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

Unified Diff: src/runtime.js

Issue 1398733002: Move builtin JavaScript sources into own directory. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also move macros.py file. Created 5 years, 2 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/regexp.js ('k') | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
deleted file mode 100644
index 5a4c75a42a4db01b24f76044654640977f9a561d..0000000000000000000000000000000000000000
--- a/src/runtime.js
+++ /dev/null
@@ -1,253 +0,0 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This files contains runtime support implemented in JavaScript.
-
-// CAUTION: Some of the functions specified in this file are called
-// directly from compiled code. These are the functions with names in
-// ALL CAPS. The compiled code passes the first argument in 'this'.
-
-
-// The following declarations are shared with other native JS files.
-// They are all declared at this one spot to avoid redeclaration errors.
-var $NaN;
-var $sameValue;
-var $sameValueZero;
-var $toPositiveInteger;
-
-var harmony_tolength = false;
-
-(function(global, utils) {
-
-%CheckIsBootstrapping();
-
-var GlobalArray = global.Array;
-var GlobalBoolean = global.Boolean;
-var GlobalString = global.String;
-var isConcatSpreadableSymbol =
- utils.ImportNow("is_concat_spreadable_symbol");
-
-// ----------------------------------------------------------------------------
-
-/* -----------------------------
- - - - H e l p e r s - - -
- -----------------------------
-*/
-
-function APPLY_PREPARE(args) {
- var length;
-
- // First check that the receiver is callable.
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
- }
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
- return length;
- }
- }
-
- length = (args == null) ? 0 : TO_UINT32(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Make sure the arguments list has the right type.
- if (args != null && !IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Function.prototype.apply");
- }
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
-function REFLECT_APPLY_PREPARE(args) {
- var length;
-
- // First check that the receiver is callable.
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kApplyNonFunction, TO_STRING(this), typeof this);
- }
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength) {
- return length;
- }
- }
-
- if (!IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Reflect.apply");
- }
-
- length = TO_LENGTH(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
-function REFLECT_CONSTRUCT_PREPARE(
- args, newTarget) {
- var length;
- var ctorOk = IS_CALLABLE(this) && %IsConstructor(this);
- var newTargetOk = IS_CALLABLE(newTarget) && %IsConstructor(newTarget);
-
- // First check whether length is a positive Smi and args is an
- // array. This is the fast case. If this fails, we do the slow case
- // that takes care of more eventualities.
- if (IS_ARRAY(args)) {
- length = args.length;
- if (%_IsSmi(length) && length >= 0 && length < kSafeArgumentsLength &&
- ctorOk && newTargetOk) {
- return length;
- }
- }
-
- if (!ctorOk) {
- if (!IS_CALLABLE(this)) {
- throw %make_type_error(kCalledNonCallable, TO_STRING(this));
- } else {
- throw %make_type_error(kNotConstructor, TO_STRING(this));
- }
- }
-
- if (!newTargetOk) {
- if (!IS_CALLABLE(newTarget)) {
- throw %make_type_error(kCalledNonCallable, TO_STRING(newTarget));
- } else {
- throw %make_type_error(kNotConstructor, TO_STRING(newTarget));
- }
- }
-
- if (!IS_SPEC_OBJECT(args)) {
- throw %make_type_error(kWrongArgs, "Reflect.construct");
- }
-
- length = TO_LENGTH(args.length);
-
- // We can handle any number of apply arguments if the stack is
- // big enough, but sanity check the value to avoid overflow when
- // multiplying with pointer size.
- if (length > kSafeArgumentsLength) throw %make_range_error(kStackOverflow);
-
- // Return the length which is the number of arguments to copy to the
- // stack. It is guaranteed to be a small integer at this point.
- return length;
-}
-
-
-function CONCAT_ITERABLE_TO_ARRAY(iterable) {
- return %concat_iterable_to_array(this, iterable);
-};
-
-
-/* -------------------------------------
- - - - C o n v e r s i o n s - - -
- -------------------------------------
-*/
-
-// ES5, section 9.12
-function SameValue(x, y) {
- if (typeof x != typeof y) return false;
- if (IS_NUMBER(x)) {
- if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
- // x is +0 and y is -0 or vice versa.
- if (x === 0 && y === 0 && %_IsMinusZero(x) != %_IsMinusZero(y)) {
- return false;
- }
- }
- if (IS_SIMD_VALUE(x)) return %SimdSameValue(x, y);
- return x === y;
-}
-
-
-// ES6, section 7.2.4
-function SameValueZero(x, y) {
- if (typeof x != typeof y) return false;
- if (IS_NUMBER(x)) {
- if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
- }
- if (IS_SIMD_VALUE(x)) return %SimdSameValueZero(x, y);
- return x === y;
-}
-
-
-function ConcatIterableToArray(target, iterable) {
- var index = target.length;
- for (var element of iterable) {
- %AddElement(target, index++, element);
- }
- return target;
-}
-
-
-/* ---------------------------------
- - - - U t i l i t i e s - - -
- ---------------------------------
-*/
-
-
-// ES6, draft 10-14-14, section 22.1.3.1.1
-function IsConcatSpreadable(O) {
- if (!IS_SPEC_OBJECT(O)) return false;
- var spreadable = O[isConcatSpreadableSymbol];
- if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O);
- return TO_BOOLEAN(spreadable);
-}
-
-
-function ToPositiveInteger(x, rangeErrorIndex) {
- var i = TO_INTEGER_MAP_MINUS_ZERO(x);
- if (i < 0) throw MakeRangeError(rangeErrorIndex);
- return i;
-}
-
-//----------------------------------------------------------------------------
-
-// NOTE: Setting the prototype for Array must take place as early as
-// possible due to code generation for array literals. When
-// generating code for a array literal a boilerplate array is created
-// that is cloned when running the code. It is essential that the
-// boilerplate gets the right prototype.
-%FunctionSetPrototype(GlobalArray, new GlobalArray(0));
-
-// ----------------------------------------------------------------------------
-// Exports
-
-$NaN = %GetRootNaN();
-$sameValue = SameValue;
-$sameValueZero = SameValueZero;
-$toPositiveInteger = ToPositiveInteger;
-
-%InstallToContext([
- "apply_prepare_builtin", APPLY_PREPARE,
- "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
- "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE,
- "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE,
-]);
-
-%InstallToContext([
- "concat_iterable_to_array", ConcatIterableToArray,
-]);
-
-})
« no previous file with comments | « src/regexp.js ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698