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

Revert of Use function wrapper argument to expose internal arrays to native...

Revert of Use function wrapper argument to expose internal arrays to native scripts. (patchset #2 id:20001 of https://codereview.chromium.org/1127983003/)

Reason for revert:
custom snapshot builder failing.

Original issue's description:
> Use function wrapper argument to expose internal arrays to native scripts.
>
> R=jkummerow@chromium.org
>
> Committed: https://crrev.com/a9b5a1795449d94387218d25baed2c2b3c4fbadc
> Cr-Commit-Position: refs/heads/master@{#28354}

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

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

Cr-Commit-Position: refs/heads/master@{#28355}
parent a9b5a179
...@@ -19,12 +19,7 @@ var $innerArrayEvery; ...@@ -19,12 +19,7 @@ var $innerArrayEvery;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = exports.InternalArray;
var InternalPackedArray = exports.InternalPackedArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -217,7 +217,7 @@ class Genesis BASE_EMBEDDED { ...@@ -217,7 +217,7 @@ class Genesis BASE_EMBEDDED {
HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
#undef DECLARE_FEATURE_INITIALIZATION #undef DECLARE_FEATURE_INITIALIZATION
Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins,
const char* name, const char* name,
ElementsKind elements_kind); ElementsKind elements_kind);
bool InstallNatives(); bool InstallNatives();
...@@ -233,8 +233,6 @@ class Genesis BASE_EMBEDDED { ...@@ -233,8 +233,6 @@ class Genesis BASE_EMBEDDED {
void InstallJSFunctionResultCaches(); void InstallJSFunctionResultCaches();
void InitializeNormalizedMapCaches(); void InitializeNormalizedMapCaches();
void RemoveExportObjects();
enum ExtensionTraversalState { enum ExtensionTraversalState {
UNVISITED, VISITED, INSTALLED UNVISITED, VISITED, INSTALLED
}; };
...@@ -309,15 +307,19 @@ class Genesis BASE_EMBEDDED { ...@@ -309,15 +307,19 @@ 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,
Handle<String> source, int argc, Vector<const char> name,
Handle<Object> argv[]); Handle<String> source);
static bool CompileScriptCached(Isolate* isolate,
static bool CompileExtension(Isolate* isolate, v8::Extension* extension); Vector<const char> name,
Handle<String> source,
SourceCodeCache* cache,
v8::Extension* extension,
Handle<Context> top_context,
bool use_runtime_context);
Isolate* isolate_; Isolate* isolate_;
Handle<Context> result_; Handle<Context> result_;
...@@ -1439,45 +1441,34 @@ void Genesis::InitializeExperimentalGlobal() { ...@@ -1439,45 +1441,34 @@ 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(); return CompileNative(isolate, name, source_code);
Handle<Object> exports = isolate->builtin_exports_object();
Handle<Object> args[] = {global, shared, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
} }
bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
HandleScope scope(isolate);
Vector<const char> name = ExperimentalNatives::GetScriptName(index); Vector<const char> name = ExperimentalNatives::GetScriptName(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(); return CompileNative(isolate, name, source_code);
Handle<Object> exports = isolate->builtin_exports_object();
Handle<Object> args[] = {global, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
} }
bool Genesis::CompileExtraBuiltin(Isolate* isolate, int index) { bool Genesis::CompileExtraBuiltin(Isolate* isolate, int index) {
HandleScope scope(isolate);
Vector<const char> name = ExtraNatives::GetScriptName(index); Vector<const char> name = ExtraNatives::GetScriptName(index);
Handle<String> source_code = Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<ExtraNatives>(index); isolate->bootstrapper()->SourceLookup<ExtraNatives>(index);
Handle<Object> global = isolate->global_object(); return CompileNative(isolate, name, source_code);
Handle<Object> exports = isolate->builtin_exports_object();
Handle<Object> args[] = {global, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
} }
bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name, bool Genesis::CompileNative(Isolate* isolate,
Handle<String> source, int argc, Vector<const char> name,
Handle<Object> argv[]) { Handle<String> source) {
HandleScope scope(isolate);
SuppressDebug compiling_natives(isolate->debug()); SuppressDebug compiling_natives(isolate->debug());
// During genesis, the boilerplate for stack overflow won't work until the // During genesis, the boilerplate for stack overflow won't work until the
// environment has been at least partially initialized. Add a stack check // environment has been at least partially initialized. Add a stack check
...@@ -1485,72 +1476,78 @@ bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name, ...@@ -1485,72 +1476,78 @@ bool Genesis::CompileNative(Isolate* isolate, Vector<const char> name,
StackLimitCheck check(isolate); StackLimitCheck check(isolate);
if (check.HasOverflowed()) return false; if (check.HasOverflowed()) return false;
Handle<Context> context(isolate->context()); bool result = CompileScriptCached(isolate,
name,
Handle<String> script_name = source,
isolate->factory()->NewStringFromUtf8(name).ToHandleChecked(); NULL,
Handle<SharedFunctionInfo> function_info = Compiler::CompileScript( NULL,
source, script_name, 0, 0, false, false, Handle<Object>(), context, NULL, Handle<Context>(isolate->context()),
NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false); true);
DCHECK(isolate->has_pending_exception() != result);
DCHECK(context->IsNativeContext()); if (!result) isolate->clear_pending_exception();
return result;
Handle<Context> runtime_context(context->runtime_context());
Handle<JSBuiltinsObject> receiver(context->builtins());
Handle<JSFunction> fun =
isolate->factory()->NewFunctionFromSharedFunctionInfo(function_info,
runtime_context);
// 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.
return !Execution::Call(isolate, Handle<JSFunction>::cast(wrapper), receiver,
argc, argv).is_null();
} }
bool Genesis::CompileExtension(Isolate* isolate, v8::Extension* extension) { bool Genesis::CompileScriptCached(Isolate* isolate,
Vector<const char> name,
Handle<String> source,
SourceCodeCache* cache,
v8::Extension* extension,
Handle<Context> top_context,
bool use_runtime_context) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<SharedFunctionInfo> function_info; Handle<SharedFunctionInfo> function_info;
Handle<String> source =
isolate->factory()
->NewExternalStringFromOneByte(extension->source())
.ToHandleChecked();
DCHECK(source->IsOneByteRepresentation());
// If we can't find the function in the cache, we compile a new // If we can't find the function in the cache, we compile a new
// function and insert it into the cache. // function and insert it into the cache.
Vector<const char> name = CStrVector(extension->name()); if (cache == NULL || !cache->Lookup(name, &function_info)) {
SourceCodeCache* cache = isolate->bootstrapper()->extensions_cache(); DCHECK(source->IsOneByteRepresentation());
Handle<Context> context(isolate->context());
DCHECK(context->IsNativeContext());
if (!cache->Lookup(name, &function_info)) {
Handle<String> script_name = Handle<String> script_name =
factory->NewStringFromUtf8(name).ToHandleChecked(); factory->NewStringFromUtf8(name).ToHandleChecked();
function_info = Compiler::CompileScript( function_info = Compiler::CompileScript(
source, script_name, 0, 0, false, false, Handle<Object>(), context, source, script_name, 0, 0, false, false, Handle<Object>(), top_context,
extension, NULL, ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, extension, NULL, ScriptCompiler::kNoCompileOptions,
false); use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE, false);
if (function_info.is_null()) return false; if (function_info.is_null()) return false;
cache->Add(name, function_info); if (cache != NULL) cache->Add(name, function_info);
} }
// Set up the function context. Conceptually, we should clone the // Set up the function context. Conceptually, we should clone the
// function before overwriting the context but since we're in a // function before overwriting the context but since we're in a
// single-threaded environment it is not strictly necessary. // single-threaded environment it is not strictly necessary.
DCHECK(top_context->IsNativeContext());
Handle<Context> context =
Handle<Context>(use_runtime_context
? Handle<Context>(top_context->runtime_context())
: top_context);
Handle<JSFunction> fun = Handle<JSFunction> fun =
factory->NewFunctionFromSharedFunctionInfo(function_info, context); factory->NewFunctionFromSharedFunctionInfo(function_info, context);
// Call function using either the runtime object or the global // Call function using either the runtime object or the global
// object as the receiver. Provide no parameters. // object as the receiver. Provide no parameters.
Handle<Object> receiver = isolate->global_object(); Handle<Object> receiver =
return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null(); Handle<Object>(use_runtime_context
? top_context->builtins()
: top_context->global_object(),
isolate);
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();
} }
...@@ -1821,9 +1818,10 @@ void Genesis::InitializeGlobal_harmony_tostring() { ...@@ -1821,9 +1818,10 @@ void Genesis::InitializeGlobal_harmony_tostring() {
} }
Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, Handle<JSFunction> Genesis::InstallInternalArray(
const char* name, Handle<JSBuiltinsObject> builtins,
ElementsKind elements_kind) { const char* name,
ElementsKind elements_kind) {
// --- I n t e r n a l A r r a y --- // --- I n t e r n a l A r r a y ---
// An array constructor on the builtins object that works like // An array constructor on the builtins object that works like
// the public Array constructor, except that its prototype // the public Array constructor, except that its prototype
...@@ -1832,9 +1830,9 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, ...@@ -1832,9 +1830,9 @@ Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
// must not be leaked to user code. // must not be leaked to user code.
Handle<JSObject> prototype = Handle<JSObject> prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED); factory()->NewJSObject(isolate()->object_function(), TENURED);
Handle<JSFunction> array_function = Handle<JSFunction> array_function = InstallFunction(
InstallFunction(target, name, JS_ARRAY_TYPE, JSArray::kSize, prototype, builtins, name, JS_ARRAY_TYPE, JSArray::kSize,
Builtins::kInternalArrayCode); prototype, Builtins::kInternalArrayCode);
InternalArrayConstructorStub internal_array_constructor_stub(isolate()); InternalArrayConstructorStub internal_array_constructor_stub(isolate());
Handle<Code> code = internal_array_constructor_stub.GetCode(); Handle<Code> code = internal_array_constructor_stub.GetCode();
...@@ -1912,27 +1910,6 @@ bool Genesis::InstallNatives() { ...@@ -1912,27 +1910,6 @@ bool Genesis::InstallNatives() {
native_context()->set_runtime_context(*context); native_context()->set_runtime_context(*context);
// 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);
if (FLAG_expose_natives_as != nullptr) {
Handle<String> shared_key = factory()->NewStringFromAsciiChecked("shared");
Handle<String> builtin_exports_key =
factory()->NewStringFromAsciiChecked("builtin_exports");
JSObject::AddProperty(builtins, shared_key, shared, NONE);
JSObject::AddProperty(builtins, builtin_exports_key, builtin_exports, NONE);
}
{ // -- S c r i p t { // -- S c r i p t
// Builtin functions for Script. // Builtin functions for Script.
Handle<JSFunction> script_fun = InstallFunction( Handle<JSFunction> script_fun = InstallFunction(
...@@ -2105,13 +2082,13 @@ bool Genesis::InstallNatives() { ...@@ -2105,13 +2082,13 @@ bool Genesis::InstallNatives() {
// through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT // through a common bottleneck that would make the SMI_ONLY -> FAST_ELEMENT
// transition easy to trap. Moreover, they rarely are smi-only. // transition easy to trap. Moreover, they rarely are smi-only.
{ {
HandleScope scope(isolate()); Handle<JSFunction> array_function =
Handle<JSObject> builtin_exports = InstallInternalArray(builtins, "InternalArray", FAST_HOLEY_ELEMENTS);
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); native_context()->set_internal_array_function(*array_function);
InstallInternalArray(builtin_exports, "InternalPackedArray", FAST_ELEMENTS); }
{
InstallInternalArray(builtins, "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
...@@ -2204,15 +2181,13 @@ bool Genesis::InstallNatives() { ...@@ -2204,15 +2181,13 @@ bool Genesis::InstallNatives() {
#undef INSTALL_PUBLIC_SYMBOL #undef INSTALL_PUBLIC_SYMBOL
} }
// Install natives. Everything exported to experimental natives is also // Install natives.
// shared to regular natives.
TransferNamedProperties(builtin_exports, shared);
int i = Natives::GetDebuggerCount(); int i = Natives::GetDebuggerCount();
if (!CompileBuiltin(isolate(), i, shared)) return false; if (!CompileBuiltin(isolate(), i)) 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, shared)) return false; if (!CompileBuiltin(isolate(), i)) return false;
} }
InstallNativeFunctions(); InstallNativeFunctions();
...@@ -2416,11 +2391,6 @@ bool Genesis::InstallExtraNatives() { ...@@ -2416,11 +2391,6 @@ bool Genesis::InstallExtraNatives() {
} }
void Genesis::RemoveExportObjects() {
native_context_->set_builtin_exports_object(Smi::FromInt(0));
}
static void InstallBuiltinFunctionId(Handle<JSObject> holder, static void InstallBuiltinFunctionId(Handle<JSObject> holder,
const char* function_name, const char* function_name,
BuiltinFunctionId id) { BuiltinFunctionId id) {
...@@ -2683,7 +2653,17 @@ bool Genesis::InstallExtension(Isolate* isolate, ...@@ -2683,7 +2653,17 @@ bool Genesis::InstallExtension(Isolate* isolate,
} }
} }
// We do not expect this to throw an exception. Change this if it does. // We do not expect this to throw an exception. Change this if it does.
bool result = CompileExtension(isolate, extension); Handle<String> source_code =
isolate->factory()
->NewExternalStringFromOneByte(extension->source())
.ToHandleChecked();
bool result = CompileScriptCached(isolate,
CStrVector(extension->name()),
source_code,
isolate->bootstrapper()->extensions_cache(),
extension,
Handle<Context>(isolate->context()),
false);
DCHECK(isolate->has_pending_exception() != result); DCHECK(isolate->has_pending_exception() != result);
if (!result) { if (!result) {
// We print out the name of the extension that fail to install. // We print out the name of the extension that fail to install.
...@@ -2934,10 +2914,8 @@ Genesis::Genesis(Isolate* isolate, ...@@ -2934,10 +2914,8 @@ Genesis::Genesis(Isolate* isolate,
// We can only de-serialize a context if the isolate was initialized from // We can only de-serialize a context if the isolate was initialized from
// a snapshot. Otherwise we have to build the context from scratch. // a snapshot. Otherwise we have to build the context from scratch.
// Also create a context from scratch to expose natives, if required by flag.
Handle<FixedArray> outdated_contexts; Handle<FixedArray> outdated_contexts;
if (FLAG_expose_natives_as != nullptr || if (!isolate->initialized_from_snapshot() ||
!isolate->initialized_from_snapshot() ||
!Snapshot::NewContextFromSnapshot(isolate, global_proxy, !Snapshot::NewContextFromSnapshot(isolate, global_proxy,
&outdated_contexts) &outdated_contexts)
.ToHandle(&native_context_)) { .ToHandle(&native_context_)) {
...@@ -2993,9 +2971,6 @@ Genesis::Genesis(Isolate* isolate, ...@@ -2993,9 +2971,6 @@ Genesis::Genesis(Isolate* isolate,
InitializeExperimentalGlobal(); InitializeExperimentalGlobal();
if (!InstallExperimentalNatives()) return; if (!InstallExperimentalNatives()) return;
if (!InstallExtraNatives()) return; if (!InstallExtraNatives()) return;
// Exports are no longer needed.
RemoveExportObjects();
} }
// The serializer cannot serialize typed arrays. Reset those typed arrays // The serializer cannot serialize typed arrays. Reset those typed arrays
......
...@@ -185,8 +185,7 @@ enum BindingFlags { ...@@ -185,8 +185,7 @@ enum BindingFlags {
V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \ V(MAP_ITERATOR_MAP_INDEX, Map, map_iterator_map) \
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(BUILTIN_EXPORTS_OBJECT_INDEX, Object, builtin_exports_object)
// A table of all script contexts. Every loaded top-level script with top-level // A table of all script contexts. Every loaded top-level script with top-level
...@@ -423,7 +422,6 @@ class Context: public FixedArray { ...@@ -423,7 +422,6 @@ 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,
BUILTIN_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.
// Scavenge treats them as strong references. // Scavenge treats them as strong references.
......
...@@ -16,13 +16,7 @@ var $createDate; ...@@ -16,13 +16,7 @@ var $createDate;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalDate = global.Date; var GlobalDate = global.Date;
var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
// This file contains date support implemented in JavaScript. // This file contains date support implemented in JavaScript.
......
...@@ -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, exports) { (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, exports) { (function(global, shared, exports) {
'use strict'; 'use strict';
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
(function(global, exports) { (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, exports) { (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, exports) { (function(global, shared, exports) {
'use strict'; 'use strict';
......
...@@ -5,16 +5,10 @@ ...@@ -5,16 +5,10 @@
var $spreadArguments; var $spreadArguments;
var $spreadIterable; var $spreadIterable;
(function(global, exports) { (function(global, shared, exports) {
'use strict'; 'use strict';
// -------------------------------------------------------------------
// Imports
var InternalArray = exports.InternalArray;
// -------------------------------------------------------------------
function SpreadArguments() { function SpreadArguments() {
var count = %_ArgumentsLength(); var count = %_ArgumentsLength();
var args = new InternalArray(); var args = new 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, exports) { (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, exports) { (function(global, shared, exports) {
"use strict"; "use strict";
......
...@@ -10,11 +10,7 @@ var $jsonSerializeAdapter; ...@@ -10,11 +10,7 @@ var $jsonSerializeAdapter;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalJSON = global.JSON; var GlobalJSON = global.JSON;
var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -16,11 +16,7 @@ var $min; ...@@ -16,11 +16,7 @@ var $min;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = shared.InternalArray;
//------------------------------------------------------------------- //-------------------------------------------------------------------
......
...@@ -35,14 +35,7 @@ var MakeTypeErrorEmbedded; ...@@ -35,14 +35,7 @@ var MakeTypeErrorEmbedded;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
var GlobalError; var GlobalError;
var GlobalTypeError; var GlobalTypeError;
var GlobalRangeError; var GlobalRangeError;
...@@ -51,6 +44,8 @@ var GlobalSyntaxError; ...@@ -51,6 +44,8 @@ var GlobalSyntaxError;
var GlobalReferenceError; var GlobalReferenceError;
var GlobalEvalError; var GlobalEvalError;
// -------------------------------------------------------------------
var kMessages = { var kMessages = {
// Error // Error
constructor_is_generator: ["Class constructor may not be a generator"], constructor_is_generator: ["Class constructor may not be a generator"],
......
...@@ -16,12 +16,8 @@ var $observeNativeObjectNotifierPerformChange; ...@@ -16,12 +16,8 @@ var $observeNativeObjectNotifierPerformChange;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalObject = global.Object; var GlobalObject = global.Object;
var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
......
...@@ -1694,6 +1694,9 @@ class JSReceiver: public HeapObject { ...@@ -1694,6 +1694,9 @@ class JSReceiver: public HeapObject {
// Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable. // Forward declaration for JSObject::GetOrCreateHiddenPropertiesHashTable.
class ObjectHashTable; class ObjectHashTable;
// Forward declaration for JSObject::Copy.
class AllocationSite;
// The JSObject describes real heap allocated JavaScript objects with // The JSObject describes real heap allocated JavaScript objects with
// properties. // properties.
...@@ -2154,6 +2157,7 @@ class JSObject: public JSReceiver { ...@@ -2154,6 +2157,7 @@ class JSObject: public JSReceiver {
// Copy object. // Copy object.
enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 }; enum DeepCopyHints { kNoHints = 0, kObjectIsShallow = 1 };
static Handle<JSObject> Copy(Handle<JSObject> object);
MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy( MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy(
Handle<JSObject> object, Handle<JSObject> object,
AllocationSiteUsageContext* site_context, AllocationSiteUsageContext* site_context,
......
...@@ -18,11 +18,6 @@ var $promiseValue; ...@@ -18,11 +18,6 @@ var $promiseValue;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Status values: 0 = pending, +1 = resolved, -1 = rejected // Status values: 0 = pending, +1 = resolved, -1 = rejected
......
...@@ -13,13 +13,7 @@ var harmony_unicode_regexps = false; ...@@ -13,13 +13,7 @@ var harmony_unicode_regexps = false;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var InternalPackedArray = shared.InternalPackedArray;
// -------------------------------------------------------------------
// Property of the builtins object for recording the result of the last // Property of the builtins object for recording the result of the last
// regexp match. The property $regexpLastMatchInfo includes the matchIndices // regexp match. The property $regexpLastMatchInfo includes the matchIndices
......
...@@ -10,13 +10,8 @@ var $stringSubstring; ...@@ -10,13 +10,8 @@ var $stringSubstring;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// -------------------------------------------------------------------
// Imports
var GlobalRegExp = global.RegExp; var GlobalRegExp = global.RegExp;
var GlobalString = global.String; var GlobalString = global.String;
var InternalArray = shared.InternalArray;
var InternalPackedArray = shared.InternalPackedArray;
//------------------------------------------------------------------- //-------------------------------------------------------------------
......
...@@ -12,17 +12,9 @@ var $getTemplateCallSite; ...@@ -12,17 +12,9 @@ var $getTemplateCallSite;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ------------------------------------------------------------------- var callSiteCache = new global.Map;
// Imports var mapGetFn = global.Map.prototype.get;
var mapSetFn = global.Map.prototype.set;
var GlobalMap = global.Map;
var InternalArray = shared.InternalArray;
// -------------------------------------------------------------------
var callSiteCache = new GlobalMap;
var mapGetFn = GlobalMap.prototype.get;
var mapSetFn = GlobalMap.prototype.set;
function SameCallSiteElements(rawStrings, other) { function SameCallSiteElements(rawStrings, other) {
......
...@@ -11,12 +11,8 @@ ...@@ -11,12 +11,8 @@
%CheckIsBootstrapping(); %CheckIsBootstrapping();
//- ------------------------------------------------------------------
// Imports
var GlobalObject = global.Object; var GlobalObject = global.Object;
var GlobalArray = global.Array; var GlobalArray = global.Array;
var InternalArray = shared.InternalArray;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Define internal helper functions. // Define internal helper functions.
......
...@@ -36,15 +36,11 @@ var $toNameArray; ...@@ -36,15 +36,11 @@ var $toNameArray;
%CheckIsBootstrapping(); %CheckIsBootstrapping();
// ----------------------------------------------------------------------------
// Imports
var GlobalArray = global.Array; var GlobalArray = global.Array;
var GlobalBoolean = global.Boolean; 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 = shared.InternalArray;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
......
...@@ -5430,56 +5430,3 @@ TEST(PreprocessStackTrace) { ...@@ -5430,56 +5430,3 @@ TEST(PreprocessStackTrace) {
CHECK(!element->IsCode()); CHECK(!element->IsCode());
} }
} }
static bool shared_has_been_collected = false;
static bool builtin_exports_has_been_collected = false;
static void SharedHasBeenCollected(
const v8::WeakCallbackInfo<v8::Persistent<v8::Object>>& data) {
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();
}
TEST(BootstrappingExports) {
FLAG_expose_natives_as = "natives";
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
if (Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) return;
shared_has_been_collected = false;
builtin_exports_has_been_collected = false;
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);
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"));
}
shared.SetWeak(&shared, SharedHasBeenCollected,
v8::WeakCallbackType::kParameter);
builtin_exports.SetWeak(&builtin_exports, BuiltinExportsHasBeenCollected,
v8::WeakCallbackType::kParameter);
CcTest::heap()->CollectAllAvailableGarbage("fire weak callbacks");
CHECK(shared_has_been_collected);
CHECK(builtin_exports_has_been_collected);
}
...@@ -32,13 +32,13 @@ ...@@ -32,13 +32,13 @@
var a = Array(); var a = Array();
for (var i = 0; i < 1000; i++) { for (var i = 0; i < 1000; i++) {
var ai = natives.shared.InternalArray(10000); var ai = natives.InternalArray(10000);
assertFalse(%HaveSameMap(ai, a)); assertFalse(%HaveSameMap(ai, a));
assertTrue(%HasFastObjectElements(ai)); assertTrue(%HasFastObjectElements(ai));
} }
for (var i = 0; i < 1000; i++) { for (var i = 0; i < 1000; i++) {
var ai = new natives.shared.InternalArray(10000); var ai = new natives.InternalArray(10000);
assertFalse(%HaveSameMap(ai, a)); assertFalse(%HaveSameMap(ai, a));
assertTrue(%HasFastObjectElements(ai)); assertTrue(%HasFastObjectElements(ai));
} }
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