Commit 7f4fa3b8 authored by yangguo's avatar yangguo Committed by Commit bot

Call builtin code wrapped in functions from the bootstrapper.

For the moment, we only pass the global object (the one we are setting up).
A few smaller changes were necessary to avoid failures in
test-object-observe/DontLeakContextOnObserve. Otherwise the global object
would be retained by being context allocated, leading to test failure.

R=jkummerow@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28331}
parent 256ae736
......@@ -5,7 +5,7 @@
var $iteratorCreateResultObject;
var $arrayValues;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -156,4 +156,4 @@ TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
$iteratorCreateResultObject = CreateIteratorResultObject;
$arrayValues = ArrayValues;
})();
})
......@@ -11,7 +11,7 @@ var $arraySlice;
var $arraySplice;
var $arrayUnshift;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -1595,4 +1595,4 @@ $arraySlice = ArraySlice;
$arraySplice = ArraySplice;
$arrayUnshift = ArrayUnshift;
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -93,4 +93,4 @@ $installFunctions(GlobalArrayBuffer.prototype, DONT_ENUM, [
"slice", ArrayBufferSlice
]);
})();
})
......@@ -1547,8 +1547,22 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
? top_context->builtins()
: top_context->global_object(),
isolate);
return !Execution::Call(
isolate, fun, receiver, 0, NULL).is_null();
MaybeHandle<Object> result;
if (extension == NULL) {
// For non-extension scripts, run script to get the function wrapper.
Handle<Object> wrapper;
if (!Execution::Call(isolate, fun, receiver, 0, NULL).ToHandle(&wrapper)) {
return false;
}
// Then run the function wrapper.
Handle<Object> global_obj(top_context->global_object(), isolate);
Handle<Object> args[] = {global_obj};
result = Execution::Call(isolate, Handle<JSFunction>::cast(wrapper),
receiver, arraysize(args), args);
} else {
result = Execution::Call(isolate, fun, receiver, 0, NULL);
}
return !result.is_null();
}
......@@ -1889,16 +1903,9 @@ bool Genesis::InstallNatives() {
builtins->set_global_proxy(native_context()->global_proxy());
// Set up the 'global' properties of the builtins object. The
// 'global' property that refers to the global object is the only
// way to get from code running in the builtins context to the
// global object.
// Set up the 'builtin' property, which refers to the js builtins object.
static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
Handle<String> global_string =
factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("global"));
Handle<Object> global_obj(native_context()->global_object(), isolate());
JSObject::AddProperty(builtins, global_string, global_obj, attributes);
Handle<String> builtins_string =
factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("builtins"));
JSObject::AddProperty(builtins, builtins_string, builtins, attributes);
......
......@@ -7,7 +7,7 @@ var $mapIteratorNext;
var $setIteratorNext;
var $setValues;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -188,4 +188,4 @@ $installFunctions(GlobalMap.prototype, DONT_ENUM, [
$mapEntries = MapEntries;
$mapIteratorNext = MapIteratorNextJS;
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -437,4 +437,4 @@ $installFunctions(GlobalMap.prototype, DONT_ENUM, [
"forEach", MapForEach
]);
})();
})
......@@ -10,7 +10,7 @@ var $createDate;
// -------------------------------------------------------------------
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -823,4 +823,4 @@ $installFunctions(GlobalDate.prototype, DONT_ENUM, [
// Expose to the global scope.
$createDate = CreateDate;
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -73,7 +73,7 @@ function GeneratorObjectIterator() {
function GeneratorFunctionConstructor(arg1) { // length == 1
var source = $newFunctionString(arguments, 'function*');
var global_proxy = %GlobalProxy(global);
var global_proxy = %GlobalProxy(GeneratorFunctionConstructor);
// Compile the string in the constructor and not a helper so that errors
// appear to come from here.
var f = %_CallFunction(global_proxy, %CompileString(source, true));
......@@ -110,4 +110,4 @@ $setFunctionName(GeneratorObjectIterator, symbolIterator);
%InternalSetPrototype(GeneratorFunction, GlobalFunction);
%SetCode(GeneratorFunction, GeneratorFunctionConstructor);
})();
})
......@@ -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() {
(function(global, shared, exports) {
'use strict';
......@@ -56,4 +56,4 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [
"includes", ArrayIncludes
]);
})();
})
......@@ -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() {
(function(global, shared, exports) {
'use strict';
......@@ -287,4 +287,4 @@ $installFunctions(GlobalArray.prototype, DONT_ENUM, [
"fill", ArrayFill
]);
})();
})
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
//
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -43,4 +43,4 @@ $installFunctions(GlobalObject, DONT_ENUM, [
"assign", ObjectAssign
]);
})();
})
......@@ -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() {
(function(global, shared, exports) {
'use strict';
......@@ -15,4 +15,4 @@ $installFunctions(GlobalReflect, DONT_ENUM, [
"construct", $reflectConstruct
]);
})();
})
......@@ -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() {
(function(global, shared, exports) {
'use strict';
......@@ -31,4 +31,4 @@ function RegExpGetFlags() {
RegExpGetFlags, null, DONT_ENUM);
%SetNativeFlag(RegExpGetFlags);
})();
})
......@@ -5,7 +5,7 @@
var $spreadArguments;
var $spreadIterable;
(function() {
(function(global, shared, exports) {
'use strict';
......@@ -40,4 +40,4 @@ function SpreadIterable(collection) {
$spreadArguments = SpreadArguments;
$spreadIterable = SpreadIterable;
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -15,4 +15,4 @@ $installConstants(GlobalSymbol, [
"toStringTag", symbolToStringTag
]);
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -117,4 +117,4 @@ endmacro
TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
})();
})
......@@ -8,7 +8,7 @@
* Intl object is a single object that has some named properties,
* all of which are constructors.
*/
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -2058,4 +2058,4 @@ $overrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
}
);
})();
})
......@@ -4,7 +4,7 @@
var $jsonSerializeAdapter;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -239,4 +239,4 @@ $jsonSerializeAdapter = function(key, object) {
return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
}
})();
})
......@@ -10,7 +10,7 @@ var $floor;
var $max;
var $min;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -360,4 +360,4 @@ $floor = MathFloorJS;
$max = MathMax;
$min = MathMin;
})();
})
......@@ -31,7 +31,7 @@ var MakeReferenceErrorEmbedded;
var MakeSyntaxErrorEmbedded;
var MakeTypeErrorEmbedded;
(function() {
(function(global, shared, exports) {
%CheckIsBootstrapping();
......@@ -1051,7 +1051,7 @@ var captureStackTrace = function captureStackTrace(obj, cons_opt) {
// Define special error type constructors.
function DefineError(f) {
function DefineError(global, f) {
// Store the error function in both the global object
// and the runtime object. The function is fetched
// from the runtime object when throwing errors from
......@@ -1094,13 +1094,13 @@ function DefineError(f) {
return f;
};
GlobalError = DefineError(function Error() { });
GlobalEvalError = DefineError(function EvalError() { });
GlobalRangeError = DefineError(function RangeError() { });
GlobalReferenceError = DefineError(function ReferenceError() { });
GlobalSyntaxError = DefineError(function SyntaxError() { });
GlobalTypeError = DefineError(function TypeError() { });
GlobalURIError = DefineError(function URIError() { });
GlobalError = DefineError(global, function Error() { });
GlobalEvalError = DefineError(global, function EvalError() { });
GlobalRangeError = DefineError(global, function RangeError() { });
GlobalReferenceError = DefineError(global, function ReferenceError() { });
GlobalSyntaxError = DefineError(global, function SyntaxError() { });
GlobalTypeError = DefineError(global, function TypeError() { });
GlobalURIError = DefineError(global, function URIError() { });
GlobalError.captureStackTrace = captureStackTrace;
......@@ -1236,4 +1236,4 @@ $stackOverflowBoilerplate = MakeRangeError(kStackOverflow);
%DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack',
StackTraceGetter, StackTraceSetter, DONT_ENUM);
})();
})
......@@ -10,7 +10,7 @@ var $observeNativeObjectObserve;
var $observeNativeObjectGetNotifier;
var $observeNativeObjectNotifierPerformChange;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -684,4 +684,4 @@ $observeNativeObjectObserve = NativeObjectObserve;
$observeNativeObjectGetNotifier = NativeObjectGetNotifier;
$observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange;
})();
})
......@@ -12,7 +12,7 @@ var $promiseHasUserDefinedRejectHandler;
var $promiseStatus;
var $promiseValue;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -391,4 +391,4 @@ $promiseHasUserDefinedRejectHandler = PromiseHasUserDefinedRejectHandler;
$promiseStatus = promiseStatus;
$promiseValue = promiseValue;
})();
})
......@@ -10,7 +10,7 @@ var $proxyDerivedKeysTrap;
var $proxyDerivedSetTrap;
var $proxyEnumerate;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -198,4 +198,4 @@ $proxyDerivedKeysTrap = DerivedKeysTrap;
$proxyDerivedSetTrap = DerivedSetTrap;
$proxyEnumerate = ProxyEnumerate;
})();
})
......@@ -9,7 +9,7 @@ var $regexpLastMatchInfoOverride;
var harmony_regexps = false;
var harmony_unicode_regexps = false;
(function() {
(function(global, shared, exports) {
%CheckIsBootstrapping();
......@@ -442,4 +442,4 @@ for (var i = 1; i < 10; ++i) {
$regexpExecNoTests = RegExpExecNoTests;
$regexpExec = DoRegExpExec;
})();
})
......@@ -83,7 +83,7 @@ var $toPrimitive;
var $toString;
var $toUint32;
(function() {
(function(global, shared, exports) {
%CheckIsBootstrapping();
......@@ -997,4 +997,4 @@ $toPrimitive = ToPrimitive;
$toString = ToString;
$toUint32 = ToUint32;
})();
})
......@@ -1278,9 +1278,8 @@ RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) {
RUNTIME_FUNCTION(Runtime_GlobalProxy) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(Object, global, 0);
if (!global->IsJSGlobalObject()) return isolate->heap()->null_value();
return JSGlobalObject::cast(global)->global_proxy();
CONVERT_ARG_CHECKED(JSFunction, function, 0);
return function->context()->global_proxy();
}
......
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -101,4 +101,4 @@ $setFunctionName(StringPrototypeIterator, symbolIterator);
%AddNamedProperty(GlobalString.prototype, symbolIterator,
StringPrototypeIterator, DONT_ENUM);
})();
})
......@@ -6,7 +6,7 @@ var $stringCharAt;
var $stringIndexOf;
var $stringSubstring;
(function() {
(function(global, shared, exports) {
%CheckIsBootstrapping();
......@@ -1171,4 +1171,4 @@ $stringCharAt = StringCharAtJS;
$stringIndexOf = StringIndexOfJS;
$stringSubstring = StringSubstring;
})();
})
......@@ -12,7 +12,7 @@
var $symbolToString;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -114,4 +114,4 @@ $installFunctions(GlobalObject, DONT_ENUM, [
$symbolToString = SymbolToString;
})();
})
......@@ -6,7 +6,7 @@
var $getTemplateCallSite;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -70,4 +70,4 @@ $getTemplateCallSite = function(siteObj, rawStrings, hash) {
return SetCachedCallSite(%ObjectFreeze(siteObj), hash);
}
})();
})
......@@ -26,7 +26,7 @@
var kMath;
var rempio2result;
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -1027,4 +1027,4 @@ $installFunctions(GlobalMath, DONT_ENUM, [
%SetInlineBuiltinFlag(MathSin);
%SetInlineBuiltinFlag(MathCos);
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -457,4 +457,4 @@ $installFunctions(GlobalDataView.prototype, DONT_ENUM, [
"setFloat64", DataViewSetFloat64JS
]);
})();
})
......@@ -5,7 +5,7 @@
// This file contains support for URI manipulations written in
// JavaScript.
(function() {
(function(global, shared, exports) {
"use strict";
......@@ -40,7 +40,7 @@ function isAlphaNumeric(cc) {
return false;
}
//Lazily initialized.
// Lazily initialized.
var hexCharCodeArray = 0;
function URIAddEncodedOctetToBuffer(octet, result, index) {
......@@ -365,4 +365,4 @@ $installFunctions(global, DONT_ENUM, [
"encodeURIComponent", URIEncodeComponent
]);
})();
})
......@@ -32,7 +32,7 @@ var $setUpLockedPrototype;
var $toCompletePropertyDescriptor;
var $toNameArray;
(function() {
(function(global, shared, exports) {
%CheckIsBootstrapping();
......@@ -212,7 +212,7 @@ function GlobalParseFloat(string) {
function GlobalEval(x) {
if (!IS_STRING(x)) return x;
var global_proxy = %GlobalProxy(global);
var global_proxy = %GlobalProxy(GlobalEval);
var f = %CompileString(x, false);
if (!IS_FUNCTION(f)) return f;
......@@ -322,7 +322,7 @@ function ObjectPropertyIsEnumerable(V) {
function ObjectDefineGetter(name, fun) {
var receiver = this;
if (receiver == null && !IS_UNDETECTABLE(receiver)) {
receiver = %GlobalProxy(global);
receiver = %GlobalProxy(ObjectDefineGetter);
}
if (!IS_SPEC_FUNCTION(fun)) {
throw MakeTypeError(kObjectGetterExpectingFunction);
......@@ -338,7 +338,7 @@ function ObjectDefineGetter(name, fun) {
function ObjectLookupGetter(name) {
var receiver = this;
if (receiver == null && !IS_UNDETECTABLE(receiver)) {
receiver = %GlobalProxy(global);
receiver = %GlobalProxy(ObjectLookupGetter);
}
return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), GETTER);
}
......@@ -347,7 +347,7 @@ function ObjectLookupGetter(name) {
function ObjectDefineSetter(name, fun) {
var receiver = this;
if (receiver == null && !IS_UNDETECTABLE(receiver)) {
receiver = %GlobalProxy(global);
receiver = %GlobalProxy(ObjectDefineSetter);
}
if (!IS_SPEC_FUNCTION(fun)) {
throw MakeTypeError(kObjectSetterExpectingFunction);
......@@ -363,7 +363,7 @@ function ObjectDefineSetter(name, fun) {
function ObjectLookupSetter(name) {
var receiver = this;
if (receiver == null && !IS_UNDETECTABLE(receiver)) {
receiver = %GlobalProxy(global);
receiver = %GlobalProxy(ObjectLookupSetter);
}
return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER);
}
......@@ -1893,7 +1893,7 @@ function NewFunctionString(args, function_token) {
function FunctionConstructor(arg1) { // length == 1
var source = NewFunctionString(arguments, 'function');
var global_proxy = %GlobalProxy(global);
var global_proxy = %GlobalProxy(FunctionConstructor);
// Compile the string in the constructor and not a helper so that errors
// appear to come from here.
var f = %_CallFunction(global_proxy, %CompileString(source, true));
......@@ -1964,4 +1964,4 @@ $setUpLockedPrototype = SetUpLockedPrototype;
$toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
$toNameArray = ToNameArray;
})();
})
......@@ -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() {
(function(global, shared, exports) {
"use strict";
......@@ -168,4 +168,4 @@ $installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [
"delete", WeakSetDelete
]);
})();
})
......@@ -3,9 +3,11 @@
// found in the LICENSE file.
(function () {
'use strict';
extrasExports.testExtraShouldReturnFive = function () {
return 5;
};
})();
'use strict';
extrasExports.testExtraShouldReturnFive = function () {
return 5;
};
});
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