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