Commit aa4ad8ca authored by yangguo's avatar yangguo Committed by Commit bot

Do not export natives to runtime via js builtins object.

Using a temporary container object instead.

R=jkummerow@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#30175}
parent c69e2eae
......@@ -164,4 +164,8 @@ utils.Export(function(to) {
$arrayValues = ArrayValues;
utils.ExportToRuntime(function(to) {
to.ArrayValues = ArrayValues;
});
})
This diff is collapsed.
......@@ -118,6 +118,10 @@ class Bootstrapper final {
static bool CompileCodeStubBuiltin(Isolate* isolate, int index);
static bool InstallCodeStubNatives(Isolate* isolate);
static void ImportNatives(Isolate* isolate, Handle<JSObject> container);
static void ImportExperimentalNatives(Isolate* isolate,
Handle<JSObject> container);
private:
Isolate* isolate_;
typedef int NestingCounterType;
......
......@@ -4,14 +4,6 @@
var $getHash;
var $getExistingHash;
var $mapSet;
var $mapHas;
var $mapDelete;
var $setAdd;
var $setHas;
var $setDelete;
var $mapFromArray;
var $setFromArray;
(function(global, utils) {
"use strict";
......@@ -487,15 +479,8 @@ utils.InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
// Expose to the global scope.
$getHash = GetHash;
$getExistingHash = GetExistingHash;
$mapGet = MapGet;
$mapSet = MapSet;
$mapHas = MapHas;
$mapDelete = MapDelete;
$setAdd = SetAdd;
$setHas = SetHas;
$setDelete = SetDelete;
$mapFromArray = function(array) {
function MapFromArray(array) {
var map = new GlobalMap;
var length = array.length;
for (var i = 0; i < length; i += 2) {
......@@ -506,7 +491,7 @@ $mapFromArray = function(array) {
return map;
};
$setFromArray = function(array) {
function SetFromArray(array) {
var set = new GlobalSet;
var length = array.length;
for (var i = 0; i < length; ++i) {
......@@ -515,4 +500,19 @@ $setFromArray = function(array) {
return set;
};
// -----------------------------------------------------------------------
// Exports
utils.ExportToRuntime(function(to) {
to.MapGet = MapGet;
to.MapSet = MapSet;
to.MapHas = MapHas;
to.MapDelete = MapDelete;
to.SetAdd = SetAdd;
to.SetHas = SetHas;
to.SetDelete = SetDelete;
to.MapFromArray = MapFromArray;
to.SetFromArray = SetFromArray;
});
})
......@@ -880,7 +880,8 @@ utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [
"toJSON", DateToJSON
]);
// Expose to the global scope.
$createDate = CreateDate;
utils.ExportToRuntime(function(to) {
to.CreateDate = CreateDate;
});
})
......@@ -1015,7 +1015,6 @@ utils.InstallFunctions(GlobalError.prototype, DONT_ENUM,
['toString', ErrorToString]);
$errorToString = ErrorToString;
$getStackTraceLine = GetStackTraceLine;
$messageGetPositionInLine = GetPositionInLine;
$messageGetLineNumber = GetLineNumber;
$messageGetSourceLine = GetSourceLine;
......@@ -1076,4 +1075,8 @@ captureStackTrace = function captureStackTrace(obj, cons_opt) {
GlobalError.captureStackTrace = captureStackTrace;
utils.ExportToRuntime(function(to) {
to.GetStackTraceLine = GetStackTraceLine;
});
});
......@@ -2,13 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var $observeNotifyChange;
var $observeEnqueueSpliceRecord;
var $observeBeginPerformSplice;
var $observeEndPerformSplice;
var $observeNativeObjectObserve;
var $observeNativeObjectGetNotifier;
var $observeNativeObjectNotifierPerformChange;
var $observeObjectMethods;
var $observeArrayMethods;
......@@ -703,12 +699,19 @@ var removePrototypeFn = function(f, i) {
$observeObjectMethods.forEach(removePrototypeFn);
$observeArrayMethods.forEach(removePrototypeFn);
$observeNotifyChange = NotifyChange;
$observeEnqueueSpliceRecord = EnqueueSpliceRecord;
$observeBeginPerformSplice = BeginPerformSplice;
$observeEndPerformSplice = EndPerformSplice;
$observeNativeObjectObserve = NativeObjectObserve;
$observeNativeObjectGetNotifier = NativeObjectGetNotifier;
$observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange;
utils.ExportToRuntime(function(to) {
to.ObserveNotifyChange = NotifyChange;
to.ObserveEnqueueSpliceRecord = EnqueueSpliceRecord;
to.ObserveBeginPerformSplice = BeginPerformSplice;
to.ObserveEndPerformSplice = EndPerformSplice;
to.ObserveNativeObjectObserve = NativeObjectObserve;
to.ObserveNativeObjectGetNotifier = NativeObjectGetNotifier;
to.ObserveNativeObjectNotifierPerformChange =
NativeObjectNotifierPerformChange;
});
})
......@@ -14,7 +14,7 @@
var imports = UNDEFINED;
var exports = UNDEFINED;
var imports_from_experimental = UNDEFINED;
var exports_to_runtime = UNDEFINED;
// Export to other scripts.
// In normal natives, this exports functions to other normal natives.
......@@ -26,6 +26,12 @@ function Export(f) {
};
// Export to the native context for calls from the runtime.
function ExportToRuntime(f) {
f.next = exports_to_runtime;
exports_to_runtime = f;
}
// Import from other scripts.
// In normal natives, this imports from other normal natives.
// In experimental natives, this imports from other experimental natives and
......@@ -152,6 +158,13 @@ function PostNatives(utils) {
for ( ; !IS_UNDEFINED(exports); exports = exports.next) exports(container);
for ( ; !IS_UNDEFINED(imports); imports = imports.next) imports(container);
var runtime_container = {};
for ( ; !IS_UNDEFINED(exports_to_runtime);
exports_to_runtime = exports_to_runtime.next) {
exports_to_runtime(runtime_container);
}
%ImportToRuntime(runtime_container);
// Whitelist of exports from normal natives to experimental natives.
var expose_to_experimental = [
"ArrayToString",
......@@ -205,6 +218,12 @@ function PostExperimentals(utils) {
imports_from_experimental = imports_from_experimental.next) {
imports_from_experimental(experimental_exports);
}
var runtime_container = {};
for ( ; !IS_UNDEFINED(exports_to_runtime);
exports_to_runtime = exports_to_runtime.next) {
exports_to_runtime(runtime_container);
}
%ImportExperimentalToRuntime(runtime_container);
experimental_exports = UNDEFINED;
......@@ -234,6 +253,7 @@ function PostDebug(utils) {
InstallFunctions(utils, NONE, [
"Import", Import,
"Export", Export,
"ExportToRuntime", ExportToRuntime,
"ImportFromExperimental", ImportFromExperimental,
"SetFunctionName", SetFunctionName,
"InstallConstants", InstallConstants,
......@@ -246,4 +266,13 @@ InstallFunctions(utils, NONE, [
"PostDebug", PostDebug,
]);
// TODO(yangguo): run prologue.js before runtime.js
ExportToRuntime(function(to) {
to.ToNumber = $toNumber;
to.ToString = $toString;
to.ToDetailString = $toDetailString;
to.ToInteger = $toInteger;
to.ToLength = $toLength;
});
})
......@@ -2,12 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var $promiseCreate;
var $promiseResolve;
var $promiseReject;
var $promiseChain;
var $promiseCatch;
var $promiseThen;
var $promiseHasUserDefinedRejectHandler;
var $promiseStatus;
var $promiseValue;
......@@ -386,14 +380,19 @@ utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [
"catch", PromiseCatch
]);
$promiseCreate = PromiseCreate;
$promiseResolve = PromiseResolve;
$promiseReject = PromiseReject;
$promiseChain = PromiseChain;
$promiseCatch = PromiseCatch;
$promiseThen = PromiseThen;
$promiseHasUserDefinedRejectHandler = PromiseHasUserDefinedRejectHandler;
$promiseStatus = promiseStatus;
$promiseValue = promiseValue;
utils.ExportToRuntime(function(to) {
to.promiseStatus = promiseStatus;
to.promiseValue = promiseValue;
to.PromiseCreate = PromiseCreate;
to.PromiseResolve = PromiseResolve;
to.PromiseReject = PromiseReject;
to.PromiseChain = PromiseChain;
to.PromiseCatch = PromiseCatch;
to.PromiseThen = PromiseThen;
});
})
......@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var $proxyDerivedGetTrap;
var $proxyDerivedHasTrap;
var $proxyDerivedSetTrap;
var $proxyEnumerate;
(function(global, utils) {
"use strict";
......@@ -199,15 +194,17 @@ utils.InstallFunctions(Proxy, DONT_ENUM, [
// -------------------------------------------------------------------
// Exports
$proxyDerivedGetTrap = DerivedGetTrap;
$proxyDerivedHasTrap = DerivedHasTrap;
$proxyDerivedSetTrap = DerivedSetTrap;
$proxyEnumerate = ProxyEnumerate;
utils.Export(function(to) {
to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
to.ProxyDerivedKeysTrap = DerivedKeysTrap;
});
utils.ExportToRuntime(function(to) {
to.ProxyDerivedGetTrap = DerivedGetTrap;
to.ProxyDerivedHasTrap = DerivedHasTrap;
to.ProxyDerivedSetTrap = DerivedSetTrap;
to.ProxyEnumerate = ProxyEnumerate;
});
})
......@@ -915,7 +915,7 @@ function ToPositiveInteger(x, rangeErrorIndex) {
// boilerplate gets the right prototype.
%FunctionSetPrototype(GlobalArray, new GlobalArray(0));
//----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
$concatIterableToArray = ConcatIterableToArray;
$defaultNumber = DefaultNumber;
......
......@@ -24,6 +24,26 @@ RUNTIME_FUNCTION(Runtime_CheckIsBootstrapping) {
}
RUNTIME_FUNCTION(Runtime_ImportToRuntime) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
Bootstrapper::ImportNatives(isolate, container);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_ImportExperimentalToRuntime) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
Bootstrapper::ImportExperimentalNatives(isolate, container);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_Throw) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
......
......@@ -301,6 +301,8 @@ namespace internal {
#define FOR_EACH_INTRINSIC_INTERNAL(F) \
F(CheckIsBootstrapping, 0, 1) \
F(ImportToRuntime, 1, 1) \
F(ImportExperimentalToRuntime, 1, 1) \
F(Throw, 1, 1) \
F(ReThrow, 1, 1) \
F(UnwindAndFindExceptionHandler, 0, 1) \
......
......@@ -3,10 +3,8 @@
// found in the LICENSE file.
var $functionSourceString;
var $globalEval;
var $objectDefineOwnProperty;
var $objectGetOwnPropertyDescriptor;
var $toCompletePropertyDescriptor;
(function(global, utils) {
......@@ -1787,10 +1785,8 @@ function GetIterator(obj, method) {
// Exports
$functionSourceString = FunctionSourceString;
$globalEval = GlobalEval;
$objectDefineOwnProperty = DefineOwnPropertyFromAPI;
$objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
$toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
utils.ObjectDefineProperties = ObjectDefineProperties;
utils.ObjectDefineProperty = ObjectDefineProperty;
......@@ -1814,4 +1810,9 @@ utils.Export(function(to) {
to.ToNameArray = ToNameArray;
});
utils.ExportToRuntime(function(to) {
to.GlobalEval = GlobalEval;
to.ToCompletePropertyDescriptor = ToCompletePropertyDescriptor;
});
})
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