Commit 1ec55616 authored by jkummerow's avatar jkummerow Committed by Commit bot

Revert of Use shared container to manage imports/exports. (patchset #2...

Revert of Use shared container to manage imports/exports. (patchset #2 id:20001 of https://codereview.chromium.org/1143993003/)

Reason for revert:
Breaks nosnap bots

Original issue's description:
> Use shared container to manage imports/exports.
>
> Also changed string.js and math.js to adapt this change.
>
> R=jkummerow@chromium.org
>
> Committed: https://crrev.com/e25058b0b7b9831162579564fc8935d568c1ecdd
> Cr-Commit-Position: refs/heads/master@{#28521}

TBR=yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Review URL: https://codereview.chromium.org/1144163002

Cr-Commit-Position: refs/heads/master@{#28523}
parent aca4735b
...@@ -204,7 +204,6 @@ action("js2c") { ...@@ -204,7 +204,6 @@ action("js2c") {
"src/macros.py", "src/macros.py",
"src/messages.h", "src/messages.h",
"src/runtime.js", "src/runtime.js",
"src/prologue.js",
"src/v8natives.js", "src/v8natives.js",
"src/symbol.js", "src/symbol.js",
"src/array.js", "src/array.js",
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
var $iteratorCreateResultObject; var $iteratorCreateResultObject;
var $arrayValues; var $arrayValues;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -17,7 +17,7 @@ var $innerArrayLastIndexOf; ...@@ -17,7 +17,7 @@ var $innerArrayLastIndexOf;
var $innerArrayReverse; var $innerArrayReverse;
var $innerArraySort; var $innerArraySort;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -27,14 +27,8 @@ var $innerArraySort; ...@@ -27,14 +27,8 @@ var $innerArraySort;
// Imports // Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = utils.InternalArray; var InternalArray = exports.InternalArray;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = exports.InternalPackedArray;
var MathMin;
utils.Import(function(from) {
MathMin = from.MathMin;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -268,7 +262,7 @@ function SparseMove(array, start_i, del_count, len, num_additional_args) { ...@@ -268,7 +262,7 @@ function SparseMove(array, start_i, del_count, len, num_additional_args) {
// Move data to new array. // Move data to new array.
var new_array = new InternalArray( var new_array = new InternalArray(
// Clamp array length to 2^32-1 to avoid early RangeError. // Clamp array length to 2^32-1 to avoid early RangeError.
MathMin(len - del_count + num_additional_args, 0xffffffff)); $min(len - del_count + num_additional_args, 0xffffffff));
var big_indices; var big_indices;
var indices = %GetArrayKeys(array, len); var indices = %GetArrayKeys(array, len);
if (IS_NUMBER(indices)) { if (IS_NUMBER(indices)) {
......
...@@ -2,27 +2,15 @@ ...@@ -2,27 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArrayBuffer = global.ArrayBuffer; var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function ArrayBufferConstructor(length) { // length = 1 function ArrayBufferConstructor(length) { // length = 1
...@@ -56,16 +44,16 @@ function ArrayBufferSlice(start, end) { ...@@ -56,16 +44,16 @@ function ArrayBufferSlice(start, end) {
var first; var first;
var byte_length = %_ArrayBufferGetByteLength(this); var byte_length = %_ArrayBufferGetByteLength(this);
if (relativeStart < 0) { if (relativeStart < 0) {
first = MathMax(byte_length + relativeStart, 0); first = $max(byte_length + relativeStart, 0);
} else { } else {
first = MathMin(relativeStart, byte_length); first = $min(relativeStart, byte_length);
} }
var relativeEnd = IS_UNDEFINED(end) ? byte_length : end; var relativeEnd = IS_UNDEFINED(end) ? byte_length : end;
var fin; var fin;
if (relativeEnd < 0) { if (relativeEnd < 0) {
fin = MathMax(byte_length + relativeEnd, 0); fin = $max(byte_length + relativeEnd, 0);
} else { } else {
fin = MathMin(relativeEnd, byte_length); fin = $min(relativeEnd, byte_length);
} }
if (fin < first) { if (fin < first) {
......
...@@ -307,15 +307,14 @@ class Genesis BASE_EMBEDDED { ...@@ -307,15 +307,14 @@ class Genesis BASE_EMBEDDED {
FunctionMode function_mode); FunctionMode function_mode);
void SetStrongFunctionInstanceDescriptor(Handle<Map> map); void SetStrongFunctionInstanceDescriptor(Handle<Map> map);
static bool CompileBuiltin(Isolate* isolate, int index); static bool CompileBuiltin(Isolate* isolate, int index,
Handle<JSObject> shared);
static bool CompileExperimentalBuiltin(Isolate* isolate, int index); static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
static bool CompileExtraBuiltin(Isolate* isolate, int index); static bool CompileExtraBuiltin(Isolate* isolate, int index);
static bool CompileNative(Isolate* isolate, Vector<const char> name, static bool CompileNative(Isolate* isolate, Vector<const char> name,
Handle<String> source, int argc, Handle<String> source, int argc,
Handle<Object> argv[]); Handle<Object> argv[]);
static bool CallUtilsFunction(Isolate* isolate, const char* name);
static bool CompileExtension(Isolate* isolate, v8::Extension* extension); static bool CompileExtension(Isolate* isolate, v8::Extension* extension);
Isolate* isolate_; Isolate* isolate_;
...@@ -1443,13 +1442,14 @@ void Genesis::InitializeExperimentalGlobal() { ...@@ -1443,13 +1442,14 @@ void Genesis::InitializeExperimentalGlobal() {
} }
bool Genesis::CompileBuiltin(Isolate* isolate, int index) { bool Genesis::CompileBuiltin(Isolate* isolate, int index,
Handle<JSObject> shared) {
Vector<const char> name = Natives::GetScriptName(index); Vector<const char> name = Natives::GetScriptName(index);
Handle<String> source_code = Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<Natives>(index); isolate->bootstrapper()->SourceLookup<Natives>(index);
Handle<Object> global = isolate->global_object(); Handle<Object> global = isolate->global_object();
Handle<Object> utils = isolate->natives_utils_object(); Handle<Object> exports = isolate->builtin_exports_object();
Handle<Object> args[] = {global, utils}; Handle<Object> args[] = {global, shared, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args); return CompileNative(isolate, name, source_code, arraysize(args), args);
} }
...@@ -1460,8 +1460,8 @@ bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { ...@@ -1460,8 +1460,8 @@ bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
Handle<String> source_code = Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index); isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index);
Handle<Object> global = isolate->global_object(); Handle<Object> global = isolate->global_object();
Handle<Object> utils = isolate->natives_utils_object(); Handle<Object> exports = isolate->builtin_exports_object();
Handle<Object> args[] = {global, utils}; Handle<Object> args[] = {global, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args); return CompileNative(isolate, name, source_code, arraysize(args), args);
} }
...@@ -1517,17 +1517,6 @@ bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name, ...@@ -1517,17 +1517,6 @@ bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name,
} }
bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) {
Handle<JSObject> utils =
Handle<JSObject>::cast(isolate->natives_utils_object());
Handle<String> name_string =
isolate->factory()->NewStringFromAsciiChecked(name);
Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
Handle<Object> receiver = isolate->factory()->undefined_value();
return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null();
}
bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) { bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
HandleScope scope(isolate); HandleScope scope(isolate);
...@@ -1929,11 +1918,19 @@ bool Genesis::InstallNatives() { ...@@ -1929,11 +1918,19 @@ bool Genesis::InstallNatives() {
native_context()->set_runtime_context(*context); native_context()->set_runtime_context(*context);
// Set up the utils object as shared container between native scripts. // Set up shared object to set up cross references between native scripts.
Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); // "shared" is used for cross references between native scripts that are part
JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, // of the snapshot. "builtin_exports" is used for experimental natives.
"utils container for native scripts"); Handle<JSObject> shared =
native_context()->set_natives_utils_object(*utils); factory()->NewJSObject(isolate()->object_function());
JSObject::NormalizeProperties(shared, CLEAR_INOBJECT_PROPERTIES, 16,
"container to share between native scripts");
Handle<JSObject> builtin_exports =
factory()->NewJSObject(isolate()->object_function());
JSObject::NormalizeProperties(builtin_exports, CLEAR_INOBJECT_PROPERTIES, 16,
"container to export to experimental natives");
native_context()->set_builtin_exports_object(*builtin_exports);
Handle<JSObject> extras_exports = Handle<JSObject> extras_exports =
factory()->NewJSObject(isolate()->object_function()); factory()->NewJSObject(isolate()->object_function());
...@@ -1942,8 +1939,8 @@ bool Genesis::InstallNatives() { ...@@ -1942,8 +1939,8 @@ bool Genesis::InstallNatives() {
native_context()->set_extras_exports_object(*extras_exports); native_context()->set_extras_exports_object(*extras_exports);
if (FLAG_expose_natives_as != NULL) { if (FLAG_expose_natives_as != NULL) {
Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils"); Handle<String> shared_key = factory()->NewStringFromAsciiChecked("shared");
JSObject::AddProperty(builtins, utils_key, utils, NONE); JSObject::AddProperty(builtins, shared_key, shared, NONE);
} }
{ // -- S c r i p t { // -- S c r i p t
...@@ -2119,12 +2116,12 @@ bool Genesis::InstallNatives() { ...@@ -2119,12 +2116,12 @@ bool Genesis::InstallNatives() {
// transition easy to trap. Moreover, they rarely are smi-only. // transition easy to trap. Moreover, they rarely are smi-only.
{ {
HandleScope scope(isolate()); HandleScope scope(isolate());
Handle<JSObject> utils = Handle<JSObject> builtin_exports =
Handle<JSObject>::cast(isolate()->natives_utils_object()); Handle<JSObject>::cast(isolate()->builtin_exports_object());
Handle<JSFunction> array_function = Handle<JSFunction> array_function = InstallInternalArray(
InstallInternalArray(utils, "InternalArray", FAST_HOLEY_ELEMENTS); builtin_exports, "InternalArray", FAST_HOLEY_ELEMENTS);
native_context()->set_internal_array_function(*array_function); native_context()->set_internal_array_function(*array_function);
InstallInternalArray(utils, "InternalPackedArray", FAST_ELEMENTS); InstallInternalArray(builtin_exports, "InternalPackedArray", FAST_ELEMENTS);
} }
{ // -- S e t I t e r a t o r { // -- S e t I t e r a t o r
...@@ -2224,16 +2221,17 @@ bool Genesis::InstallNatives() { ...@@ -2224,16 +2221,17 @@ bool Genesis::InstallNatives() {
#undef INSTALL_PUBLIC_SYMBOL #undef INSTALL_PUBLIC_SYMBOL
} }
// Install natives. Everything exported to experimental natives is also
// shared to regular natives.
TransferNamedProperties(builtin_exports, shared);
int i = Natives::GetDebuggerCount(); int i = Natives::GetDebuggerCount();
if (!CompileBuiltin(isolate(), i)) return false; if (!CompileBuiltin(isolate(), i, shared)) return false;
if (!InstallJSBuiltins(builtins)) return false; if (!InstallJSBuiltins(builtins)) return false;
for (++i; i < Natives::GetBuiltinsCount(); ++i) { for (++i; i < Natives::GetBuiltinsCount(); ++i) {
if (!CompileBuiltin(isolate(), i)) return false; if (!CompileBuiltin(isolate(), i, shared)) return false;
} }
if (!CallUtilsFunction(isolate(), "PostNatives")) return false;
InstallNativeFunctions(); InstallNativeFunctions();
auto function_cache = auto function_cache =
...@@ -2546,8 +2544,9 @@ bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { ...@@ -2546,8 +2544,9 @@ bool Genesis::InstallSpecialObjects(Handle<Context> native_context) {
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate); Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
JSObject::AddProperty(Error, name, stack_trace_limit, NONE); JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
// By now the utils object is useless and can be removed. Handle<Object> builtin_exports(native_context->builtin_exports_object(),
native_context->set_natives_utils_object(*factory->undefined_value()); isolate);
native_context->set_builtin_exports_object(Smi::FromInt(0));
// Expose the natives in global if a name for it is specified. // Expose the natives in global if a name for it is specified.
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
...@@ -2557,6 +2556,9 @@ bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { ...@@ -2557,6 +2556,9 @@ bool Genesis::InstallSpecialObjects(Handle<Context> native_context) {
if (natives_key->AsArrayIndex(&dummy_index)) return true; if (natives_key->AsArrayIndex(&dummy_index)) return true;
Handle<JSBuiltinsObject> natives(global->builtins()); Handle<JSBuiltinsObject> natives(global->builtins());
JSObject::AddProperty(global, natives_key, natives, DONT_ENUM); JSObject::AddProperty(global, natives_key, natives, DONT_ENUM);
Handle<String> builtin_exports_key =
factory->NewStringFromAsciiChecked("builtin_exports");
JSObject::AddProperty(natives, builtin_exports_key, builtin_exports, NONE);
} }
// Expose the stack trace symbol to native JS. // Expose the stack trace symbol to native JS.
......
...@@ -7,7 +7,7 @@ var $mapIteratorNext; ...@@ -7,7 +7,7 @@ var $mapIteratorNext;
var $setIteratorNext; var $setIteratorNext;
var $setValues; var $setValues;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -188,7 +188,7 @@ enum BindingFlags { ...@@ -188,7 +188,7 @@ enum BindingFlags {
V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \ V(SET_ITERATOR_MAP_INDEX, Map, set_iterator_map) \
V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \ V(ARRAY_VALUES_ITERATOR_INDEX, JSFunction, array_values_iterator) \
V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \ V(SCRIPT_CONTEXT_TABLE_INDEX, ScriptContextTable, script_context_table) \
V(NATIVES_UTILS_OBJECT_INDEX, Object, natives_utils_object) \ V(BUILTIN_EXPORTS_OBJECT_INDEX, Object, builtin_exports_object) \
V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_exports_object) V(EXTRAS_EXPORTS_OBJECT_INDEX, JSObject, extras_exports_object)
...@@ -428,7 +428,7 @@ class Context: public FixedArray { ...@@ -428,7 +428,7 @@ class Context: public FixedArray {
SCRIPT_CONTEXT_TABLE_INDEX, SCRIPT_CONTEXT_TABLE_INDEX,
MAP_CACHE_INDEX, MAP_CACHE_INDEX,
TO_LENGTH_FUN_INDEX, TO_LENGTH_FUN_INDEX,
NATIVES_UTILS_OBJECT_INDEX, BUILTIN_EXPORTS_OBJECT_INDEX,
EXTRAS_EXPORTS_OBJECT_INDEX, EXTRAS_EXPORTS_OBJECT_INDEX,
// Properties from here are treated as weak references by the full GC. // Properties from here are treated as weak references by the full GC.
......
...@@ -10,7 +10,7 @@ var $createDate; ...@@ -10,7 +10,7 @@ var $createDate;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -20,15 +20,7 @@ var $createDate; ...@@ -20,15 +20,7 @@ var $createDate;
// Imports // Imports
var GlobalDate = global.Date; var GlobalDate = global.Date;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
var MathAbs;
var MathFloor;
utils.Import(function(from) {
MathAbs = from.MathAbs;
MathFloor = from.MathFloor;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -109,7 +101,7 @@ function MakeDate(day, time) { ...@@ -109,7 +101,7 @@ function MakeDate(day, time) {
// is no way that the time can be within range even after UTC // is no way that the time can be within range even after UTC
// conversion we return NaN immediately instead of relying on // conversion we return NaN immediately instead of relying on
// TimeClip to do it. // TimeClip to do it.
if (MathAbs(time) > MAX_TIME_BEFORE_UTC) return NAN; if ($abs(time) > MAX_TIME_BEFORE_UTC) return NAN;
return time; return time;
} }
...@@ -117,7 +109,7 @@ function MakeDate(day, time) { ...@@ -117,7 +109,7 @@ function MakeDate(day, time) {
// ECMA 262 - 15.9.1.14 // ECMA 262 - 15.9.1.14
function TimeClip(time) { function TimeClip(time) {
if (!$isFinite(time)) return NAN; if (!$isFinite(time)) return NAN;
if (MathAbs(time) > MAX_TIME_MS) return NAN; if ($abs(time) > MAX_TIME_MS) return NAN;
return TO_INTEGER(time); return TO_INTEGER(time);
} }
...@@ -244,8 +236,8 @@ function LocalTimezoneString(date) { ...@@ -244,8 +236,8 @@ function LocalTimezoneString(date) {
var timezoneOffset = -TIMEZONE_OFFSET(date); var timezoneOffset = -TIMEZONE_OFFSET(date);
var sign = (timezoneOffset >= 0) ? 1 : -1; var sign = (timezoneOffset >= 0) ? 1 : -1;
var hours = MathFloor((sign * timezoneOffset)/60); var hours = $floor((sign * timezoneOffset)/60);
var min = MathFloor((sign * timezoneOffset)%60); var min = $floor((sign * timezoneOffset)%60);
var gmt = ' GMT' + ((sign == 1) ? '+' : '-') + var gmt = ' GMT' + ((sign == 1) ? '+' : '-') +
TwoDigitString(hours) + TwoDigitString(min); TwoDigitString(hours) + TwoDigitString(min);
return gmt + ' (' + timezone + ')'; return gmt + ' (' + timezone + ')';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, exports) {
'use strict'; 'use strict';
......
...@@ -8,54 +8,43 @@ var $innerArrayFind; ...@@ -8,54 +8,43 @@ var $innerArrayFind;
var $innerArrayFindIndex; var $innerArrayFindIndex;
var $arrayFrom; var $arrayFrom;
(function(global, utils) { (function(global, exports) {
'use strict'; 'use strict';
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalSymbol = global.Symbol; var GlobalSymbol = global.Symbol;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
function InnerArrayCopyWithin(target, start, end, array, length) { function InnerArrayCopyWithin(target, start, end, array, length) {
target = TO_INTEGER(target); target = TO_INTEGER(target);
var to; var to;
if (target < 0) { if (target < 0) {
to = MathMax(length + target, 0); to = $max(length + target, 0);
} else { } else {
to = MathMin(target, length); to = $min(target, length);
} }
start = TO_INTEGER(start); start = TO_INTEGER(start);
var from; var from;
if (start < 0) { if (start < 0) {
from = MathMax(length + start, 0); from = $max(length + start, 0);
} else { } else {
from = MathMin(start, length); from = $min(start, length);
} }
end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); end = IS_UNDEFINED(end) ? length : TO_INTEGER(end);
var final; var final;
if (end < 0) { if (end < 0) {
final = MathMax(length + end, 0); final = $max(length + end, 0);
} else { } else {
final = MathMin(end, length); final = $min(end, length);
} }
var count = MathMin(final - from, length - to); var count = $min(final - from, length - to);
var direction = 1; var direction = 1;
if (from < to && to < (from + count)) { if (from < to && to < (from + count)) {
direction = -1; direction = -1;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
(function(global, utils) { (function(global, exports) {
"use strict"; "use strict";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, exports) {
'use strict'; 'use strict';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, exports) {
'use strict'; 'use strict';
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
var $spreadArguments; var $spreadArguments;
var $spreadIterable; var $spreadIterable;
(function(global, utils) { (function(global, exports) {
'use strict'; 'use strict';
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var InternalArray = utils.InternalArray; var InternalArray = exports.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, exports) {
"use strict"; "use strict";
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, exports) {
"use strict"; "use strict";
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
var $iteratorPrototype; var $iteratorPrototype;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
var $jsonSerializeAdapter; var $jsonSerializeAdapter;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -14,15 +14,7 @@ var $jsonSerializeAdapter; ...@@ -14,15 +14,7 @@ var $jsonSerializeAdapter;
// Imports // Imports
var GlobalJSON = global.JSON; var GlobalJSON = global.JSON;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -191,7 +183,7 @@ function JSONStringify(value, replacer, space) { ...@@ -191,7 +183,7 @@ function JSONStringify(value, replacer, space) {
} }
var gap; var gap;
if (IS_NUMBER(space)) { if (IS_NUMBER(space)) {
space = MathMax(0, MathMin($toInteger(space), 10)); space = $max(0, $min($toInteger(space), 10));
gap = %_SubString(" ", 0, space); gap = %_SubString(" ", 0, space);
} else if (IS_STRING(space)) { } else if (IS_STRING(space)) {
if (space.length > 10) { if (space.length > 10) {
......
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
var rngstate; // Initialized to a Uint32Array during genesis. var rngstate; // Initialized to a Uint32Array during genesis.
(function(global, utils) { var $abs;
var $exp;
var $floor;
var $max;
var $min;
(function(global, shared, exports) {
"use strict"; "use strict";
...@@ -14,7 +20,7 @@ var rngstate; // Initialized to a Uint32Array during genesis. ...@@ -14,7 +20,7 @@ var rngstate; // Initialized to a Uint32Array during genesis.
// Imports // Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
//------------------------------------------------------------------- //-------------------------------------------------------------------
...@@ -351,15 +357,11 @@ $installFunctions(Math, DONT_ENUM, [ ...@@ -351,15 +357,11 @@ $installFunctions(Math, DONT_ENUM, [
%SetForceInlineFlag(MathSqrtJS); %SetForceInlineFlag(MathSqrtJS);
%SetForceInlineFlag(MathTrunc); %SetForceInlineFlag(MathTrunc);
// ------------------------------------------------------------------- // Expose to the global scope.
// Exports $abs = MathAbs;
$exp = MathExp;
utils.Export(function(to) { $floor = MathFloorJS;
to.MathAbs = MathAbs; $max = MathMax;
to.MathExp = MathExp; $min = MathMin;
to.MathFloor = MathFloorJS;
to.MathMax = MathMax;
to.MathMin = MathMin;
});
}) })
...@@ -31,7 +31,7 @@ var MakeReferenceErrorEmbedded; ...@@ -31,7 +31,7 @@ var MakeReferenceErrorEmbedded;
var MakeSyntaxErrorEmbedded; var MakeSyntaxErrorEmbedded;
var MakeTypeErrorEmbedded; var MakeTypeErrorEmbedded;
(function(global, utils) { (function(global, shared, exports) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
...@@ -39,17 +39,7 @@ var MakeTypeErrorEmbedded; ...@@ -39,17 +39,7 @@ var MakeTypeErrorEmbedded;
// Imports // Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
var StringCharAt;
var StringIndexOf;
var StringSubstring;
utils.Import(function(from) {
StringCharAt = from.StringCharAt;
StringIndexOf = from.StringIndexOf;
StringSubstring = from.StringSubstring;
});
// ------------------------------------------------------------------- // -------------------------------------------------------------------
...@@ -255,7 +245,7 @@ function ScriptLocationFromPosition(position, ...@@ -255,7 +245,7 @@ function ScriptLocationFromPosition(position,
var line_ends = this.line_ends; var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1; var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line]; var end = line_ends[line];
if (end > 0 && %_CallFunction(this.source, end - 1, StringCharAt) == '\r') { if (end > 0 && %_CallFunction(this.source, end - 1, $stringCharAt) == '\r') {
end--; end--;
} }
var column = position - start; var column = position - start;
...@@ -378,7 +368,7 @@ function ScriptSourceLine(opt_line) { ...@@ -378,7 +368,7 @@ function ScriptSourceLine(opt_line) {
var line_ends = this.line_ends; var line_ends = this.line_ends;
var start = line == 0 ? 0 : line_ends[line - 1] + 1; var start = line == 0 ? 0 : line_ends[line - 1] + 1;
var end = line_ends[line]; var end = line_ends[line];
return %_CallFunction(this.source, start, end, StringSubstring); return %_CallFunction(this.source, start, end, $stringSubstring);
} }
...@@ -469,7 +459,7 @@ function SourceLocationSourceText() { ...@@ -469,7 +459,7 @@ function SourceLocationSourceText() {
return %_CallFunction(this.script.source, return %_CallFunction(this.script.source,
this.start, this.start,
this.end, this.end,
StringSubstring); $stringSubstring);
} }
...@@ -514,7 +504,7 @@ function SourceSliceSourceText() { ...@@ -514,7 +504,7 @@ function SourceSliceSourceText() {
return %_CallFunction(this.script.source, return %_CallFunction(this.script.source,
this.from_position, this.from_position,
this.to_position, this.to_position,
StringSubstring); $stringSubstring);
} }
$setUpLockedPrototype(SourceSlice, $setUpLockedPrototype(SourceSlice,
...@@ -689,12 +679,12 @@ function CallSiteToString() { ...@@ -689,12 +679,12 @@ function CallSiteToString() {
var methodName = this.getMethodName(); var methodName = this.getMethodName();
if (functionName) { if (functionName) {
if (typeName && if (typeName &&
%_CallFunction(functionName, typeName, StringIndexOf) != 0) { %_CallFunction(functionName, typeName, $stringIndexOf) != 0) {
line += typeName + "."; line += typeName + ".";
} }
line += functionName; line += functionName;
if (methodName && if (methodName &&
(%_CallFunction(functionName, "." + methodName, StringIndexOf) != (%_CallFunction(functionName, "." + methodName, $stringIndexOf) !=
functionName.length - methodName.length - 1)) { functionName.length - methodName.length - 1)) {
line += " [as " + methodName + "]"; line += " [as " + methodName + "]";
} }
......
...@@ -10,7 +10,7 @@ var $observeNativeObjectObserve; ...@@ -10,7 +10,7 @@ var $observeNativeObjectObserve;
var $observeNativeObjectGetNotifier; var $observeNativeObjectGetNotifier;
var $observeNativeObjectNotifierPerformChange; var $observeNativeObjectNotifierPerformChange;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -21,7 +21,7 @@ var $observeNativeObjectNotifierPerformChange; ...@@ -21,7 +21,7 @@ var $observeNativeObjectNotifierPerformChange;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
// Copyright 2015 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.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
// -----------------------------------------------------------------------
// Utils
var imports = UNDEFINED;
var exports = UNDEFINED;
utils.Export = function Export(f) {
f.next = exports;
exports = f;
};
utils.Import = function Import(f) {
f.next = imports;
imports = f;
};
// -----------------------------------------------------------------------
// To be called by bootstrapper
utils.PostNatives = function() {
%CheckIsBootstrapping();
var container = {};
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
var expose_to_experimental = [
"MathMax",
"MathMin",
];
var experimental = {};
%OptimizeObjectForAddingMultipleProperties(
experimental, expose_to_experimental.length);
for (var key of expose_to_experimental) experimental[key] = container[key];
%ToFastProperties(experimental);
container = UNDEFINED;
utils.Export = UNDEFINED;
utils.PostNatives = UNDEFINED;
utils.Import = function ImportFromExperimental(f) {
f(experimental);
};
};
})
...@@ -12,7 +12,7 @@ var $promiseHasUserDefinedRejectHandler; ...@@ -12,7 +12,7 @@ var $promiseHasUserDefinedRejectHandler;
var $promiseStatus; var $promiseStatus;
var $promiseValue; var $promiseValue;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -21,7 +21,7 @@ var $promiseValue; ...@@ -21,7 +21,7 @@ var $promiseValue;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Imports // Imports
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -10,7 +10,7 @@ var $proxyDerivedKeysTrap; ...@@ -10,7 +10,7 @@ var $proxyDerivedKeysTrap;
var $proxyDerivedSetTrap; var $proxyDerivedSetTrap;
var $proxyEnumerate; var $proxyEnumerate;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -9,7 +9,7 @@ var $regexpLastMatchInfoOverride; ...@@ -9,7 +9,7 @@ var $regexpLastMatchInfoOverride;
var harmony_regexps = false; var harmony_regexps = false;
var harmony_unicode_regexps = false; var harmony_unicode_regexps = false;
(function(global, utils) { (function(global, shared, exports) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
...@@ -17,7 +17,7 @@ var harmony_unicode_regexps = false; ...@@ -17,7 +17,7 @@ var harmony_unicode_regexps = false;
// Imports // Imports
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = shared.InternalPackedArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -85,7 +85,7 @@ var $toPrimitive; ...@@ -85,7 +85,7 @@ var $toPrimitive;
var $toString; var $toString;
var $toUint32; var $toUint32;
(function(global, utils) { (function(global, shared, exports) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { var $stringCharAt;
var $stringIndexOf;
var $stringSubstring;
(function(global, shared, exports) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
...@@ -11,16 +15,8 @@ ...@@ -11,16 +15,8 @@
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var GlobalString = global.String; var GlobalString = global.String;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
var InternalPackedArray = utils.InternalPackedArray; var InternalPackedArray = shared.InternalPackedArray;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
//------------------------------------------------------------------- //-------------------------------------------------------------------
...@@ -972,7 +968,7 @@ function StringStartsWith(searchString /* position */) { // length == 1 ...@@ -972,7 +968,7 @@ function StringStartsWith(searchString /* position */) { // length == 1
} }
var s_len = s.length; var s_len = s.length;
var start = MathMin(MathMax(pos, 0), s_len); var start = $min($max(pos, 0), s_len);
var ss_len = ss.length; var ss_len = ss.length;
if (ss_len + start > s_len) { if (ss_len + start > s_len) {
return false; return false;
...@@ -1002,7 +998,7 @@ function StringEndsWith(searchString /* position */) { // length == 1 ...@@ -1002,7 +998,7 @@ function StringEndsWith(searchString /* position */) { // length == 1
} }
} }
var end = MathMin(MathMax(pos, 0), s_len); var end = $min($max(pos, 0), s_len);
var ss_len = ss.length; var ss_len = ss.length;
var start = end - ss_len; var start = end - ss_len;
if (start < 0) { if (start < 0) {
...@@ -1031,7 +1027,7 @@ function StringIncludes(searchString /* position */) { // length == 1 ...@@ -1031,7 +1027,7 @@ function StringIncludes(searchString /* position */) { // length == 1
} }
var s_len = s.length; var s_len = s.length;
var start = MathMin(MathMax(pos, 0), s_len); var start = $min($max(pos, 0), s_len);
var ss_len = ss.length; var ss_len = ss.length;
if (ss_len + start > s_len) { if (ss_len + start > s_len) {
return false; return false;
...@@ -1176,13 +1172,8 @@ $installFunctions(GlobalString.prototype, DONT_ENUM, [ ...@@ -1176,13 +1172,8 @@ $installFunctions(GlobalString.prototype, DONT_ENUM, [
"sup", StringSup "sup", StringSup
]); ]);
// ------------------------------------------------------------------- $stringCharAt = StringCharAtJS;
// Exports $stringIndexOf = StringIndexOfJS;
$stringSubstring = StringSubstring;
utils.Export(function(to) {
to.StringCharAt = StringCharAtJS;
to.StringIndexOf = StringIndexOfJS;
to.StringSubstring = StringSubstring;
});
}) })
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
var $symbolToString; var $symbolToString;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
var $getTemplateCallSite; var $getTemplateCallSite;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -16,7 +16,7 @@ var $getTemplateCallSite; ...@@ -16,7 +16,7 @@ var $getTemplateCallSite;
// Imports // Imports
var GlobalMap = global.Map; var GlobalMap = global.Map;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -26,26 +26,15 @@ ...@@ -26,26 +26,15 @@
var kMath; var kMath;
var rempio2result; var rempio2result;
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalMath = global.Math; var GlobalMath = global.Math;
var MathAbs; //-------------------------------------------------------------------
var MathExp;
utils.Import(function(from) {
MathAbs = from.MathAbs;
MathExp = from.MathExp;
});
// -------------------------------------------------------------------
define INVPIO2 = kMath[0]; define INVPIO2 = kMath[0];
define PIO2_1 = kMath[1]; define PIO2_1 = kMath[1];
...@@ -98,7 +87,7 @@ macro REMPIO2(X) ...@@ -98,7 +87,7 @@ macro REMPIO2(X)
} }
} else if (ix <= 0x413921fb) { } else if (ix <= 0x413921fb) {
// |X| ~<= 2^19*(pi/2), medium size // |X| ~<= 2^19*(pi/2), medium size
var t = MathAbs(X); var t = $abs(X);
n = (t * INVPIO2 + 0.5) | 0; n = (t * INVPIO2 + 0.5) | 0;
var r = t - n * PIO2_1; var r = t - n * PIO2_1;
var w = n * PIO2_1T; var w = n * PIO2_1T;
...@@ -280,7 +269,7 @@ function KernelTan(x, y, returnTan) { ...@@ -280,7 +269,7 @@ function KernelTan(x, y, returnTan) {
if (ix < 0x3e300000) { // |x| < 2^-28 if (ix < 0x3e300000) { // |x| < 2^-28
if (((ix | %_DoubleLo(x)) | (returnTan + 1)) == 0) { if (((ix | %_DoubleLo(x)) | (returnTan + 1)) == 0) {
// x == 0 && returnTan = -1 // x == 0 && returnTan = -1
return 1 / MathAbs(x); return 1 / $abs(x);
} else { } else {
if (returnTan == 1) { if (returnTan == 1) {
return x; return x;
...@@ -768,7 +757,7 @@ function MathSinh(x) { ...@@ -768,7 +757,7 @@ function MathSinh(x) {
x = x * 1; // Convert to number. x = x * 1; // Convert to number.
var h = (x < 0) ? -0.5 : 0.5; var h = (x < 0) ? -0.5 : 0.5;
// |x| in [0, 22]. return sign(x)*0.5*(E+E/(E+1)) // |x| in [0, 22]. return sign(x)*0.5*(E+E/(E+1))
var ax = MathAbs(x); var ax = $abs(x);
if (ax < 22) { if (ax < 22) {
// For |x| < 2^-28, sinh(x) = x // For |x| < 2^-28, sinh(x) = x
if (ax < TWO_M28) return x; if (ax < TWO_M28) return x;
...@@ -777,11 +766,11 @@ function MathSinh(x) { ...@@ -777,11 +766,11 @@ function MathSinh(x) {
return h * (t + t / (t + 1)); return h * (t + t / (t + 1));
} }
// |x| in [22, log(maxdouble)], return 0.5 * exp(|x|) // |x| in [22, log(maxdouble)], return 0.5 * exp(|x|)
if (ax < LOG_MAXD) return h * MathExp(ax); if (ax < LOG_MAXD) return h * $exp(ax);
// |x| in [log(maxdouble), overflowthreshold] // |x| in [log(maxdouble), overflowthreshold]
// overflowthreshold = 710.4758600739426 // overflowthreshold = 710.4758600739426
if (ax <= KSINH_OVERFLOW) { if (ax <= KSINH_OVERFLOW) {
var w = MathExp(0.5 * ax); var w = $exp(0.5 * ax);
var t = h * w; var t = h * w;
return t * w; return t * w;
} }
...@@ -819,7 +808,7 @@ function MathCosh(x) { ...@@ -819,7 +808,7 @@ function MathCosh(x) {
var ix = %_DoubleHi(x) & 0x7fffffff; var ix = %_DoubleHi(x) & 0x7fffffff;
// |x| in [0,0.5*log2], return 1+expm1(|x|)^2/(2*exp(|x|)) // |x| in [0,0.5*log2], return 1+expm1(|x|)^2/(2*exp(|x|))
if (ix < 0x3fd62e43) { if (ix < 0x3fd62e43) {
var t = MathExpm1(MathAbs(x)); var t = MathExpm1($abs(x));
var w = 1 + t; var w = 1 + t;
// For |x| < 2^-55, cosh(x) = 1 // For |x| < 2^-55, cosh(x) = 1
if (ix < 0x3c800000) return w; if (ix < 0x3c800000) return w;
...@@ -827,14 +816,14 @@ function MathCosh(x) { ...@@ -827,14 +816,14 @@ function MathCosh(x) {
} }
// |x| in [0.5*log2, 22], return (exp(|x|)+1/exp(|x|)/2 // |x| in [0.5*log2, 22], return (exp(|x|)+1/exp(|x|)/2
if (ix < 0x40360000) { if (ix < 0x40360000) {
var t = MathExp(MathAbs(x)); var t = $exp($abs(x));
return 0.5 * t + 0.5 / t; return 0.5 * t + 0.5 / t;
} }
// |x| in [22, log(maxdouble)], return half*exp(|x|) // |x| in [22, log(maxdouble)], return half*exp(|x|)
if (ix < 0x40862e42) return 0.5 * MathExp(MathAbs(x)); if (ix < 0x40862e42) return 0.5 * $exp($abs(x));
// |x| in [log(maxdouble), overflowthreshold] // |x| in [log(maxdouble), overflowthreshold]
if (MathAbs(x) <= KCOSH_OVERFLOW) { if ($abs(x) <= KCOSH_OVERFLOW) {
var w = MathExp(0.5 * MathAbs(x)); var w = $exp(0.5 * $abs(x));
var t = 0.5 * w; var t = 0.5 * w;
return t * w; return t * w;
} }
...@@ -937,7 +926,7 @@ define TWO53 = 9007199254740992; ...@@ -937,7 +926,7 @@ define TWO53 = 9007199254740992;
function MathLog2(x) { function MathLog2(x) {
x = x * 1; // Convert to number. x = x * 1; // Convert to number.
var ax = MathAbs(x); var ax = $abs(x);
var hx = %_DoubleHi(x); var hx = %_DoubleHi(x);
var lx = %_DoubleLo(x); var lx = %_DoubleLo(x);
var ix = hx & 0x7fffffff; var ix = hx & 0x7fffffff;
......
...@@ -2,31 +2,17 @@ ...@@ -2,31 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalArrayBuffer = global.ArrayBuffer; var GlobalArrayBuffer = global.ArrayBuffer;
var GlobalDataView = global.DataView; var GlobalDataView = global.DataView;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var MathMax;
var MathMin;
utils.Import(function(from) {
MathMax = from.MathMax;
MathMin = from.MathMin;
});
// -------------------------------------------------------------------
macro TYPED_ARRAYS(FUNCTION) macro TYPED_ARRAYS(FUNCTION)
// arrayIds below should be synchronized with Runtime_TypedArrayInitialize. // arrayIds below should be synchronized with Runtime_TypedArrayInitialize.
FUNCTION(1, Uint8Array, 1) FUNCTION(1, Uint8Array, 1)
...@@ -179,16 +165,16 @@ function NAMESubArray(begin, end) { ...@@ -179,16 +165,16 @@ function NAMESubArray(begin, end) {
var srcLength = %_TypedArrayGetLength(this); var srcLength = %_TypedArrayGetLength(this);
if (beginInt < 0) { if (beginInt < 0) {
beginInt = MathMax(0, srcLength + beginInt); beginInt = $max(0, srcLength + beginInt);
} else { } else {
beginInt = MathMin(srcLength, beginInt); beginInt = $min(srcLength, beginInt);
} }
var endInt = IS_UNDEFINED(end) ? srcLength : end; var endInt = IS_UNDEFINED(end) ? srcLength : end;
if (endInt < 0) { if (endInt < 0) {
endInt = MathMax(0, srcLength + endInt); endInt = $max(0, srcLength + endInt);
} else { } else {
endInt = MathMin(endInt, srcLength); endInt = $min(endInt, srcLength);
} }
if (endInt < beginInt) { if (endInt < beginInt) {
endInt = beginInt; endInt = beginInt;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// This file contains support for URI manipulations written in // This file contains support for URI manipulations written in
// JavaScript. // JavaScript.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Define internal helper functions. // Define internal helper functions.
......
...@@ -32,7 +32,7 @@ var $setUpLockedPrototype; ...@@ -32,7 +32,7 @@ var $setUpLockedPrototype;
var $toCompletePropertyDescriptor; var $toCompletePropertyDescriptor;
var $toNameArray; var $toNameArray;
(function(global, utils) { (function(global, shared, exports) {
%CheckIsBootstrapping(); %CheckIsBootstrapping();
...@@ -44,15 +44,7 @@ var GlobalBoolean = global.Boolean; ...@@ -44,15 +44,7 @@ var GlobalBoolean = global.Boolean;
var GlobalFunction = global.Function; var GlobalFunction = global.Function;
var GlobalNumber = global.Number; var GlobalNumber = global.Number;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = utils.InternalArray; var InternalArray = shared.InternalArray;
var MathAbs;
var StringIndexOf;
utils.Import(function(from) {
MathAbs = from.MathAbs;
StringIndexOf = from.StringIndexOf;
});
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
...@@ -1705,7 +1697,7 @@ function NumberIsSafeInteger(number) { ...@@ -1705,7 +1697,7 @@ function NumberIsSafeInteger(number) {
if (NumberIsFinite(number)) { if (NumberIsFinite(number)) {
var integral = TO_INTEGER(number); var integral = TO_INTEGER(number);
if (integral == number) { if (integral == number) {
return MathAbs(integral) <= GlobalNumber.MAX_SAFE_INTEGER; return $abs(integral) <= GlobalNumber.MAX_SAFE_INTEGER;
} }
} }
return false; return false;
...@@ -1890,7 +1882,7 @@ function NewFunctionString(args, function_token) { ...@@ -1890,7 +1882,7 @@ function NewFunctionString(args, function_token) {
// If the formal parameters string include ) - an illegal // If the formal parameters string include ) - an illegal
// character - it may make the combined function expression // character - it may make the combined function expression
// compile. We avoid this problem by checking for this early on. // compile. We avoid this problem by checking for this early on.
if (%_CallFunction(p, ')', StringIndexOf) != -1) { if (%_CallFunction(p, ')', $stringIndexOf) != -1) {
throw MakeSyntaxError(kParenthesisInArgString); throw MakeSyntaxError(kParenthesisInArgString);
} }
// If the formal parameters include an unbalanced block comment, the // If the formal parameters include an unbalanced block comment, the
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function(global, utils) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -5410,11 +5410,19 @@ TEST(PreprocessStackTrace) { ...@@ -5410,11 +5410,19 @@ TEST(PreprocessStackTrace) {
} }
static bool utils_has_been_collected = false; static bool shared_has_been_collected = false;
static bool builtin_exports_has_been_collected = false;
static void UtilsHasBeenCollected( static void SharedHasBeenCollected(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) { const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
utils_has_been_collected = true; shared_has_been_collected = true;
data.GetParameter()->Reset();
}
static void BuiltinExportsHasBeenCollected(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
builtin_exports_has_been_collected = true;
data.GetParameter()->Reset(); data.GetParameter()->Reset();
} }
...@@ -5426,50 +5434,30 @@ TEST(BootstrappingExports) { ...@@ -5426,50 +5434,30 @@ TEST(BootstrappingExports) {
if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return; if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
utils_has_been_collected = false; shared_has_been_collected = false;
builtin_exports_has_been_collected = false;
v8::Persistent<v8::Object> utils; v8::Persistent<v8::Object> shared;
v8::Persistent<v8::Object> builtin_exports;
{ {
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
v8::Handle<v8::Object> natives = v8::Handle<v8::Object> natives =
CcTest::global()->Get(v8_str("natives"))->ToObject(isolate); CcTest::global()->Get(v8_str("natives"))->ToObject(isolate);
utils.Reset(isolate, natives->Get(v8_str("utils"))->ToObject(isolate)); shared.Reset(isolate, natives->Get(v8_str("shared"))->ToObject(isolate));
natives->Delete(v8_str("utils")); natives->Delete(v8_str("shared"));
builtin_exports.Reset(
isolate, natives->Get(v8_str("builtin_exports"))->ToObject(isolate));
natives->Delete(v8_str("builtin_exports"));
} }
utils.SetWeak(&utils, UtilsHasBeenCollected, shared.SetWeak(&shared, SharedHasBeenCollected,
v8::WeakCallbackType::kParameter); v8::WeakCallbackType::kParameter);
builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
v8::WeakCallbackType::kParameter);
CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks"); CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
CHECK(utils_has_been_collected); CHECK(shared_has_been_collected);
} CHECK(builtin_exports_has_been_collected);
TEST(Regress1878) {
FLAG_allow_natives_syntax = true;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Local<v8::Function> constructor =
v8::Utils::ToLocal(CcTest::i_isolate()->internal_array_function());
CcTest::global()->Set(v8_str("InternalArray"), constructor);
v8::TryCatch try_catch;
CompileRun(
"var a = Array();"
"for (var i = 0; i < 1000; i++) {"
" var ai = new InternalArray(10000);"
" if (%HaveSameMap(ai, a)) throw Error();"
" if (!%HasFastObjectElements(ai)) throw Error();"
"}"
"for (var i = 0; i < 1000; i++) {"
" var ai = new InternalArray(10000);"
" if (%HaveSameMap(ai, a)) throw Error();"
" if (!%HasFastObjectElements(ai)) throw Error();"
"}");
CHECK(!try_catch.HasCaught());
} }
// Copyright 2012 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.
// See: http://code.google.com/p/v8/issues/detail?id=1878
// Flags: --allow-natives-syntax --expose-natives-as=natives
var a = Array();
for (var i = 0; i < 1000; i++) {
var ai = natives.builtin_exports.InternalArray(10000);
assertFalse(%HaveSameMap(ai, a));
assertTrue(%HasFastObjectElements(ai));
}
for (var i = 0; i < 1000; i++) {
var ai = new natives.builtin_exports.InternalArray(10000);
assertFalse(%HaveSameMap(ai, a));
assertTrue(%HasFastObjectElements(ai));
}
...@@ -1709,7 +1709,6 @@ ...@@ -1709,7 +1709,6 @@
'../../src/macros.py', '../../src/macros.py',
'../../src/messages.h', '../../src/messages.h',
'../../src/runtime.js', '../../src/runtime.js',
'../../src/prologue.js',
'../../src/v8natives.js', '../../src/v8natives.js',
'../../src/symbol.js', '../../src/symbol.js',
'../../src/array.js', '../../src/array.js',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment