Commit f2d6d516 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Mechanically create the right *Data object.

Also define classes NativeContext and InternalizedString. Those object
kinds were already part of our Object hierarchy but didn't have their
own class, which was inconvenient.

R=jarin@chromium.org, mslekova@chromium.org

Bug: v8:7790
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Change-Id: Ic443a2b2e34afc89bc924e845d995e3f287a2535
Reviewed-on: https://chromium-review.googlesource.com/1185592Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55402}
parent 29879461
...@@ -168,7 +168,7 @@ class Genesis BASE_EMBEDDED { ...@@ -168,7 +168,7 @@ class Genesis BASE_EMBEDDED {
Handle<JSGlobalProxy> global_proxy() { return global_proxy_; } Handle<JSGlobalProxy> global_proxy() { return global_proxy_; }
private: private:
Handle<Context> native_context() { return native_context_; } Handle<NativeContext> native_context() { return native_context_; }
// Creates some basic objects. Used for creating a context from scratch. // Creates some basic objects. Used for creating a context from scratch.
void CreateRoots(); void CreateRoots();
...@@ -297,7 +297,7 @@ class Genesis BASE_EMBEDDED { ...@@ -297,7 +297,7 @@ class Genesis BASE_EMBEDDED {
Isolate* isolate_; Isolate* isolate_;
Handle<Context> result_; Handle<Context> result_;
Handle<Context> native_context_; Handle<NativeContext> native_context_;
Handle<JSGlobalProxy> global_proxy_; Handle<JSGlobalProxy> global_proxy_;
// Temporary function maps needed only during bootstrapping. // Temporary function maps needed only during bootstrapping.
...@@ -3962,7 +3962,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate, ...@@ -3962,7 +3962,7 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Handle<JSObject> container) { Handle<JSObject> container) {
Factory* factory = isolate->factory(); Factory* factory = isolate->factory();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Context> native_context = isolate->native_context(); Handle<NativeContext> native_context = isolate->native_context();
#define EXPORT_PRIVATE_SYMBOL(NAME) \ #define EXPORT_PRIVATE_SYMBOL(NAME) \
Handle<String> NAME##_name = factory->NewStringFromAsciiChecked(#NAME); \ Handle<String> NAME##_name = factory->NewStringFromAsciiChecked(#NAME); \
JSObject::AddProperty(isolate, container, NAME##_name, factory->NAME(), NONE); JSObject::AddProperty(isolate, container, NAME##_name, factory->NAME(), NONE);
...@@ -5663,12 +5663,15 @@ Genesis::Genesis( ...@@ -5663,12 +5663,15 @@ Genesis::Genesis(
// 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. // Also create a context from scratch to expose natives, if required by flag.
if (!isolate->initialized_from_snapshot() || DCHECK(native_context_.is_null());
!Snapshot::NewContextFromSnapshot(isolate, global_proxy, if (isolate->initialized_from_snapshot()) {
context_snapshot_index, Handle<Context> context;
embedder_fields_deserializer) if (Snapshot::NewContextFromSnapshot(isolate, global_proxy,
.ToHandle(&native_context_)) { context_snapshot_index,
native_context_ = Handle<Context>(); embedder_fields_deserializer)
.ToHandle(&context)) {
native_context_ = Handle<NativeContext>::cast(context);
}
} }
if (!native_context().is_null()) { if (!native_context().is_null()) {
......
...@@ -532,8 +532,8 @@ BUILTIN(NumberFormatPrototypeFormatNumber) { ...@@ -532,8 +532,8 @@ BUILTIN(NumberFormatPrototypeFormatNumber) {
return *bound_format; return *bound_format;
} }
Handle<Context> native_context = Handle<NativeContext> native_context(isolate->context()->native_context(),
Handle<Context>(isolate->context()->native_context(), isolate); isolate);
Handle<Context> context = isolate->factory()->NewBuiltinContext( Handle<Context> context = isolate->factory()->NewBuiltinContext(
native_context, NumberFormat::ContextSlot::kLength); native_context, NumberFormat::ContextSlot::kLength);
...@@ -621,8 +621,8 @@ BUILTIN(DateTimeFormatPrototypeFormat) { ...@@ -621,8 +621,8 @@ BUILTIN(DateTimeFormatPrototypeFormat) {
return *bound_format; return *bound_format;
} }
Handle<Context> native_context = Handle<NativeContext> native_context(isolate->context()->native_context(),
Handle<Context>(isolate->context()->native_context(), isolate); isolate);
Handle<Context> context = isolate->factory()->NewBuiltinContext( Handle<Context> context = isolate->factory()->NewBuiltinContext(
native_context, DateFormat::ContextSlot::kLength); native_context, DateFormat::ContextSlot::kLength);
...@@ -1211,8 +1211,8 @@ BUILTIN(CollatorPrototypeCompare) { ...@@ -1211,8 +1211,8 @@ BUILTIN(CollatorPrototypeCompare) {
return *bound_compare; return *bound_compare;
} }
Handle<Context> native_context = Handle<NativeContext> native_context(isolate->context()->native_context(),
Handle<Context>(isolate->context()->native_context(), isolate); isolate);
Handle<Context> context = isolate->factory()->NewBuiltinContext( Handle<Context> context = isolate->factory()->NewBuiltinContext(
native_context, JSCollator::ContextSlot::kLength); native_context, JSCollator::ContextSlot::kLength);
......
This diff is collapsed.
...@@ -54,34 +54,42 @@ class HeapObjectType { ...@@ -54,34 +54,42 @@ class HeapObjectType {
Flags const flags_; Flags const flags_;
}; };
// This list is sorted such that subtypes appear before their supertypes.
// DO NOT VIOLATE THIS PROPERTY!
#define HEAP_BROKER_OBJECT_LIST(V) \ #define HEAP_BROKER_OBJECT_LIST(V) \
V(AllocationSite) \ /* Subtypes of JSObject */ \
V(JSArray) \
V(JSFunction) \
V(JSGlobalProxy) \
V(JSRegExp) \
/* Subtypes of Context */ \
V(NativeContext) \
/* Subtypes of FixedArrayBase */ \
V(BytecodeArray) \ V(BytecodeArray) \
V(FixedArray) \
V(FixedDoubleArray) \
/* Subtypes of Name */ \
V(InternalizedString) \
V(String) \
/* Subtypes of HeapObject */ \
V(AllocationSite) \
V(Cell) \ V(Cell) \
V(Code) \ V(Code) \
V(Context) \
V(FeedbackVector) \ V(FeedbackVector) \
V(FixedArray) \ V(Map) \
V(Module) \
V(ScopeInfo) \
V(ScriptContextTable) \
V(SharedFunctionInfo) \
V(Context) \
V(FixedArrayBase) \ V(FixedArrayBase) \
V(FixedDoubleArray) \
V(HeapNumber) \ V(HeapNumber) \
V(HeapObject) \
V(InternalizedString) \
V(JSArray) \
V(JSFunction) \
V(JSGlobalProxy) \
V(JSObject) \ V(JSObject) \
V(JSRegExp) \
V(Map) \
V(Module) \
V(MutableHeapNumber) \ V(MutableHeapNumber) \
V(Name) \ V(Name) \
V(NativeContext) \
V(PropertyCell) \ V(PropertyCell) \
V(ScopeInfo) \ /* Subtypes of Object */ \
V(ScriptContextTable) \ V(HeapObject)
V(SharedFunctionInfo) \
V(String)
class CompilationDependencies; class CompilationDependencies;
class JSHeapBroker; class JSHeapBroker;
......
...@@ -47,6 +47,11 @@ Context* Context::cast(Object* context) { ...@@ -47,6 +47,11 @@ Context* Context::cast(Object* context) {
return reinterpret_cast<Context*>(context); return reinterpret_cast<Context*>(context);
} }
NativeContext* NativeContext::cast(Object* context) {
DCHECK(context->IsNativeContext());
return reinterpret_cast<NativeContext*>(context);
}
void Context::set_scope_info(ScopeInfo* scope_info) { void Context::set_scope_info(ScopeInfo* scope_info) {
set(SCOPE_INFO_INDEX, scope_info); set(SCOPE_INFO_INDEX, scope_info);
} }
...@@ -68,21 +73,16 @@ void Context::set_extension(HeapObject* object) { ...@@ -68,21 +73,16 @@ void Context::set_extension(HeapObject* object) {
set(EXTENSION_INDEX, object); set(EXTENSION_INDEX, object);
} }
Context* Context::native_context() const { NativeContext* Context::native_context() const {
Object* result = get(NATIVE_CONTEXT_INDEX); Object* result = get(NATIVE_CONTEXT_INDEX);
DCHECK(IsBootstrappingOrNativeContext(this->GetIsolate(), result)); DCHECK(IsBootstrappingOrNativeContext(this->GetIsolate(), result));
return reinterpret_cast<Context*>(result); return reinterpret_cast<NativeContext*>(result);
} }
void Context::set_native_context(NativeContext* context) {
void Context::set_native_context(Context* context) {
set(NATIVE_CONTEXT_INDEX, context); set(NATIVE_CONTEXT_INDEX, context);
} }
bool Context::IsNativeContext() const {
return map()->instance_type() == NATIVE_CONTEXT_TYPE;
}
bool Context::IsFunctionContext() const { bool Context::IsFunctionContext() const {
return map()->instance_type() == FUNCTION_CONTEXT_TYPE; return map()->instance_type() == FUNCTION_CONTEXT_TYPE;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
class NativeContext;
class RegExpMatchInfo; class RegExpMatchInfo;
enum ContextLookupFlags { enum ContextLookupFlags {
...@@ -537,13 +538,11 @@ class Context : public FixedArray, public NeverReadOnlySpaceObject { ...@@ -537,13 +538,11 @@ class Context : public FixedArray, public NeverReadOnlySpaceObject {
Context* script_context(); Context* script_context();
// Compute the native context. // Compute the native context.
inline Context* native_context() const; inline NativeContext* native_context() const;
inline void set_native_context(Context* context); inline void set_native_context(NativeContext* context);
// Predicates for context types. IsNativeContext is also defined on Object // Predicates for context types. IsNativeContext is already defined on
// because we frequently have to know if arbitrary objects are natives // Object.
// contexts.
inline bool IsNativeContext() const;
inline bool IsFunctionContext() const; inline bool IsFunctionContext() const;
inline bool IsCatchContext() const; inline bool IsCatchContext() const;
inline bool IsWithContext() const; inline bool IsWithContext() const;
...@@ -642,6 +641,15 @@ class Context : public FixedArray, public NeverReadOnlySpaceObject { ...@@ -642,6 +641,15 @@ class Context : public FixedArray, public NeverReadOnlySpaceObject {
STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex);
}; };
class NativeContext : public Context {
public:
static inline NativeContext* cast(Object* context);
// TODO(neis): Move some stuff from Context here.
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(NativeContext);
};
typedef Context::Field ContextField; typedef Context::Field ContextField;
} // namespace internal } // namespace internal
......
...@@ -1353,21 +1353,19 @@ Handle<Symbol> Factory::NewPrivateFieldSymbol() { ...@@ -1353,21 +1353,19 @@ Handle<Symbol> Factory::NewPrivateFieldSymbol() {
return symbol; return symbol;
} }
Handle<Context> Factory::NewNativeContext() { Handle<NativeContext> Factory::NewNativeContext() {
Handle<Context> context = NewFixedArrayWithMap<Context>( Handle<NativeContext> context = NewFixedArrayWithMap<NativeContext>(
Heap::kNativeContextMapRootIndex, Context::NATIVE_CONTEXT_SLOTS, TENURED); Heap::kNativeContextMapRootIndex, Context::NATIVE_CONTEXT_SLOTS, TENURED);
context->set_native_context(*context); context->set_native_context(*context);
context->set_errors_thrown(Smi::kZero); context->set_errors_thrown(Smi::kZero);
context->set_math_random_index(Smi::kZero); context->set_math_random_index(Smi::kZero);
context->set_serialized_objects(*empty_fixed_array()); context->set_serialized_objects(*empty_fixed_array());
DCHECK(context->IsNativeContext());
return context; return context;
} }
Handle<Context> Factory::NewScriptContext(Handle<Context> outer, Handle<Context> Factory::NewScriptContext(Handle<NativeContext> outer,
Handle<ScopeInfo> scope_info) { Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE); DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
DCHECK(outer->IsNativeContext());
Handle<Context> context = NewFixedArrayWithMap<Context>( Handle<Context> context = NewFixedArrayWithMap<Context>(
Heap::kScriptContextMapRootIndex, scope_info->ContextLength(), TENURED); Heap::kScriptContextMapRootIndex, scope_info->ContextLength(), TENURED);
context->set_scope_info(*scope_info); context->set_scope_info(*scope_info);
...@@ -1388,7 +1386,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() { ...@@ -1388,7 +1386,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() {
} }
Handle<Context> Factory::NewModuleContext(Handle<Module> module, Handle<Context> Factory::NewModuleContext(Handle<Module> module,
Handle<Context> outer, Handle<NativeContext> outer,
Handle<ScopeInfo> scope_info) { Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE); DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
Handle<Context> context = NewFixedArrayWithMap<Context>( Handle<Context> context = NewFixedArrayWithMap<Context>(
...@@ -1483,7 +1481,7 @@ Handle<Context> Factory::NewBlockContext(Handle<Context> previous, ...@@ -1483,7 +1481,7 @@ Handle<Context> Factory::NewBlockContext(Handle<Context> previous,
return context; return context;
} }
Handle<Context> Factory::NewBuiltinContext(Handle<Context> native_context, Handle<Context> Factory::NewBuiltinContext(Handle<NativeContext> native_context,
int length) { int length) {
DCHECK_GE(length, Context::MIN_CONTEXT_SLOTS); DCHECK_GE(length, Context::MIN_CONTEXT_SLOTS);
Handle<Context> context = Handle<Context> context =
...@@ -2304,7 +2302,7 @@ Handle<JSFunction> Factory::NewFunction(const NewFunctionArgs& args) { ...@@ -2304,7 +2302,7 @@ Handle<JSFunction> Factory::NewFunction(const NewFunctionArgs& args) {
DCHECK(!args.name_.is_null()); DCHECK(!args.name_.is_null());
// Create the SharedFunctionInfo. // Create the SharedFunctionInfo.
Handle<Context> context(isolate()->native_context()); Handle<NativeContext> context(isolate()->native_context());
Handle<Map> map = args.GetMap(isolate()); Handle<Map> map = args.GetMap(isolate());
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
NewSharedFunctionInfo(args.name_, args.maybe_exported_function_data_, NewSharedFunctionInfo(args.name_, args.maybe_exported_function_data_,
...@@ -2385,8 +2383,8 @@ Handle<JSFunction> Factory::NewFunction(const NewFunctionArgs& args) { ...@@ -2385,8 +2383,8 @@ Handle<JSFunction> Factory::NewFunction(const NewFunctionArgs& args) {
Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) { Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
// Make sure to use globals from the function's context, since the function // Make sure to use globals from the function's context, since the function
// can be from a different context. // can be from a different context.
Handle<Context> native_context(function->context()->native_context(), Handle<NativeContext> native_context(function->context()->native_context(),
isolate()); isolate());
Handle<Map> new_map; Handle<Map> new_map;
if (V8_UNLIKELY(IsAsyncGeneratorFunction(function->shared()->kind()))) { if (V8_UNLIKELY(IsAsyncGeneratorFunction(function->shared()->kind()))) {
new_map = handle(native_context->async_generator_object_prototype_map(), new_map = handle(native_context->async_generator_object_prototype_map(),
...@@ -2915,7 +2913,7 @@ Handle<JSObject> Factory::NewSlowJSObjectFromMap(Handle<Map> map, int capacity, ...@@ -2915,7 +2913,7 @@ Handle<JSObject> Factory::NewSlowJSObjectFromMap(Handle<Map> map, int capacity,
Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
PretenureFlag pretenure) { PretenureFlag pretenure) {
Context* native_context = isolate()->raw_native_context(); NativeContext* native_context = isolate()->raw_native_context();
Map* map = native_context->GetInitialJSArrayMap(elements_kind); Map* map = native_context->GetInitialJSArrayMap(elements_kind);
if (map == nullptr) { if (map == nullptr) {
JSFunction* array_function = native_context->array_function(); JSFunction* array_function = native_context->array_function();
...@@ -2982,7 +2980,7 @@ void Factory::NewJSArrayStorage(Handle<JSArray> array, int length, int capacity, ...@@ -2982,7 +2980,7 @@ void Factory::NewJSArrayStorage(Handle<JSArray> array, int length, int capacity,
} }
Handle<JSWeakMap> Factory::NewJSWeakMap() { Handle<JSWeakMap> Factory::NewJSWeakMap() {
Context* native_context = isolate()->raw_native_context(); NativeContext* native_context = isolate()->raw_native_context();
Handle<Map> map(native_context->js_weak_map_fun()->initial_map(), isolate()); Handle<Map> map(native_context->js_weak_map_fun()->initial_map(), isolate());
Handle<JSWeakMap> weakmap(JSWeakMap::cast(*NewJSObjectFromMap(map)), Handle<JSWeakMap> weakmap(JSWeakMap::cast(*NewJSObjectFromMap(map)),
isolate()); isolate());
...@@ -3153,7 +3151,7 @@ static void ForFixedTypedArray(ExternalArrayType array_type, ...@@ -3153,7 +3151,7 @@ static void ForFixedTypedArray(ExternalArrayType array_type,
} }
JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
Context* native_context = isolate->context()->native_context(); NativeContext* native_context = isolate->context()->native_context();
switch (type) { switch (type) {
#define TYPED_ARRAY_FUN(Type, type, TYPE, ctype) \ #define TYPED_ARRAY_FUN(Type, type, TYPE, ctype) \
case kExternal##Type##Array: \ case kExternal##Type##Array: \
...@@ -3166,7 +3164,7 @@ JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) { ...@@ -3166,7 +3164,7 @@ JSFunction* GetTypedArrayFun(ExternalArrayType type, Isolate* isolate) {
} }
JSFunction* GetTypedArrayFun(ElementsKind elements_kind, Isolate* isolate) { JSFunction* GetTypedArrayFun(ElementsKind elements_kind, Isolate* isolate) {
Context* native_context = isolate->context()->native_context(); NativeContext* native_context = isolate->context()->native_context();
switch (elements_kind) { switch (elements_kind) {
#define TYPED_ARRAY_FUN(Type, type, TYPE, ctype) \ #define TYPED_ARRAY_FUN(Type, type, TYPE, ctype) \
case TYPE##_ELEMENTS: \ case TYPE##_ELEMENTS: \
...@@ -3729,14 +3727,12 @@ Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee, ...@@ -3729,14 +3727,12 @@ Handle<JSObject> Factory::NewArgumentsObject(Handle<JSFunction> callee,
return result; return result;
} }
Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> native_context, Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<NativeContext> context,
int number_of_properties) { int number_of_properties) {
DCHECK(native_context->IsNativeContext());
if (number_of_properties == 0) { if (number_of_properties == 0) {
// Reuse the initial map of the Object function if the literal has no // Reuse the initial map of the Object function if the literal has no
// predeclared properties. // predeclared properties.
return handle(native_context->object_function()->initial_map(), isolate()); return handle(context->object_function()->initial_map(), isolate());
} }
// We do not cache maps for too many properties or when running builtin code. // We do not cache maps for too many properties or when running builtin code.
...@@ -3747,16 +3743,15 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> native_context, ...@@ -3747,16 +3743,15 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> native_context,
// Use initial slow object proto map for too many properties. // Use initial slow object proto map for too many properties.
const int kMapCacheSize = 128; const int kMapCacheSize = 128;
if (number_of_properties > kMapCacheSize) { if (number_of_properties > kMapCacheSize) {
return handle(native_context->slow_object_with_object_prototype_map(), return handle(context->slow_object_with_object_prototype_map(), isolate());
isolate());
} }
int cache_index = number_of_properties - 1; int cache_index = number_of_properties - 1;
Handle<Object> maybe_cache(native_context->map_cache(), isolate()); Handle<Object> maybe_cache(context->map_cache(), isolate());
if (maybe_cache->IsUndefined(isolate())) { if (maybe_cache->IsUndefined(isolate())) {
// Allocate the new map cache for the native context. // Allocate the new map cache for the native context.
maybe_cache = NewWeakFixedArray(kMapCacheSize, TENURED); maybe_cache = NewWeakFixedArray(kMapCacheSize, TENURED);
native_context->set_map_cache(*maybe_cache); context->set_map_cache(*maybe_cache);
} else { } else {
// Check to see whether there is a matching element in the cache. // Check to see whether there is a matching element in the cache.
Handle<WeakFixedArray> cache = Handle<WeakFixedArray>::cast(maybe_cache); Handle<WeakFixedArray> cache = Handle<WeakFixedArray>::cast(maybe_cache);
......
...@@ -50,6 +50,7 @@ class JSSetIterator; ...@@ -50,6 +50,7 @@ class JSSetIterator;
class JSWeakMap; class JSWeakMap;
class LoadHandler; class LoadHandler;
class ModuleInfo; class ModuleInfo;
class NativeContext;
class NewFunctionArgs; class NewFunctionArgs;
class PreParsedScopeData; class PreParsedScopeData;
class PromiseResolveThenableJobTask; class PromiseResolveThenableJobTask;
...@@ -361,17 +362,18 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -361,17 +362,18 @@ class V8_EXPORT_PRIVATE Factory {
Handle<Symbol> NewPrivateFieldSymbol(); Handle<Symbol> NewPrivateFieldSymbol();
// Create a global (but otherwise uninitialized) context. // Create a global (but otherwise uninitialized) context.
Handle<Context> NewNativeContext(); Handle<NativeContext> NewNativeContext();
// Create a script context. // Create a script context.
Handle<Context> NewScriptContext(Handle<Context> outer, Handle<Context> NewScriptContext(Handle<NativeContext> outer,
Handle<ScopeInfo> scope_info); Handle<ScopeInfo> scope_info);
// Create an empty script context table. // Create an empty script context table.
Handle<ScriptContextTable> NewScriptContextTable(); Handle<ScriptContextTable> NewScriptContextTable();
// Create a module context. // Create a module context.
Handle<Context> NewModuleContext(Handle<Module> module, Handle<Context> outer, Handle<Context> NewModuleContext(Handle<Module> module,
Handle<NativeContext> outer,
Handle<ScopeInfo> scope_info); Handle<ScopeInfo> scope_info);
// Create a function or eval context. // Create a function or eval context.
...@@ -403,7 +405,8 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -403,7 +405,8 @@ class V8_EXPORT_PRIVATE Factory {
// These are similar to function context but don't have a previous // These are similar to function context but don't have a previous
// context or any scope info. These are used to store spec defined // context or any scope info. These are used to store spec defined
// context values. // context values.
Handle<Context> NewBuiltinContext(Handle<Context> native_context, int length); Handle<Context> NewBuiltinContext(Handle<NativeContext> native_context,
int length);
Handle<Struct> NewStruct(InstanceType type, Handle<Struct> NewStruct(InstanceType type,
PretenureFlag pretenure = NOT_TENURED); PretenureFlag pretenure = NOT_TENURED);
...@@ -914,7 +917,7 @@ class V8_EXPORT_PRIVATE Factory { ...@@ -914,7 +917,7 @@ class V8_EXPORT_PRIVATE Factory {
// Return a map for given number of properties using the map cache in the // Return a map for given number of properties using the map cache in the
// native context. // native context.
Handle<Map> ObjectLiteralMapFromCache(Handle<Context> native_context, Handle<Map> ObjectLiteralMapFromCache(Handle<NativeContext> native_context,
int number_of_properties); int number_of_properties);
Handle<LoadHandler> NewLoadHandler(int data_count); Handle<LoadHandler> NewLoadHandler(int data_count);
......
...@@ -26,11 +26,13 @@ void Isolate::set_context(Context* context) { ...@@ -26,11 +26,13 @@ void Isolate::set_context(Context* context) {
thread_local_top_.context_ = context; thread_local_top_.context_ = context;
} }
Handle<Context> Isolate::native_context() { Handle<NativeContext> Isolate::native_context() {
return handle(context()->native_context(), this); return handle(context()->native_context(), this);
} }
Context* Isolate::raw_native_context() { return context()->native_context(); } NativeContext* Isolate::raw_native_context() {
return context()->native_context();
}
Object* Isolate::pending_exception() { Object* Isolate::pending_exception() {
DCHECK(has_pending_exception()); DCHECK(has_pending_exception());
......
...@@ -3772,7 +3772,8 @@ MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate, ...@@ -3772,7 +3772,8 @@ MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate,
MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback( MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
Handle<Script> referrer, Handle<Object> specifier) { Handle<Script> referrer, Handle<Object> specifier) {
v8::Local<v8::Context> api_context = v8::Utils::ToLocal(native_context()); v8::Local<v8::Context> api_context =
v8::Utils::ToLocal(Handle<Context>(native_context()));
if (host_import_module_dynamically_callback_ == nullptr) { if (host_import_module_dynamically_callback_ == nullptr) {
Handle<Object> exception = Handle<Object> exception =
...@@ -3811,7 +3812,8 @@ Handle<JSObject> Isolate::RunHostInitializeImportMetaObjectCallback( ...@@ -3811,7 +3812,8 @@ Handle<JSObject> Isolate::RunHostInitializeImportMetaObjectCallback(
if (host_meta->IsTheHole(this)) { if (host_meta->IsTheHole(this)) {
host_meta = factory()->NewJSObjectWithNullProto(); host_meta = factory()->NewJSObjectWithNullProto();
if (host_initialize_import_meta_object_callback_ != nullptr) { if (host_initialize_import_meta_object_callback_ != nullptr) {
v8::Local<v8::Context> api_context = v8::Utils::ToLocal(native_context()); v8::Local<v8::Context> api_context =
v8::Utils::ToLocal(Handle<Context>(native_context()));
host_initialize_import_meta_object_callback_( host_initialize_import_meta_object_callback_(
api_context, Utils::ToLocal(module), api_context, Utils::ToLocal(module),
v8::Local<v8::Object>::Cast(v8::Utils::ToLocal(host_meta))); v8::Local<v8::Object>::Cast(v8::Utils::ToLocal(host_meta)));
......
...@@ -955,8 +955,8 @@ class Isolate : private HiddenFactory { ...@@ -955,8 +955,8 @@ class Isolate : private HiddenFactory {
void IterateThread(ThreadVisitor* v, char* t); void IterateThread(ThreadVisitor* v, char* t);
// Returns the current native context. // Returns the current native context.
inline Handle<Context> native_context(); inline Handle<NativeContext> native_context();
inline Context* raw_native_context(); inline NativeContext* raw_native_context();
Handle<Context> GetIncumbentContext(); Handle<Context> GetIncumbentContext();
......
...@@ -26,6 +26,7 @@ CAST_ACCESSOR(ConsString) ...@@ -26,6 +26,7 @@ CAST_ACCESSOR(ConsString)
CAST_ACCESSOR(ExternalOneByteString) CAST_ACCESSOR(ExternalOneByteString)
CAST_ACCESSOR(ExternalString) CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalTwoByteString) CAST_ACCESSOR(ExternalTwoByteString)
CAST_ACCESSOR(InternalizedString)
CAST_ACCESSOR(SeqOneByteString) CAST_ACCESSOR(SeqOneByteString)
CAST_ACCESSOR(SeqString) CAST_ACCESSOR(SeqString)
CAST_ACCESSOR(SeqTwoByteString) CAST_ACCESSOR(SeqTwoByteString)
......
...@@ -487,6 +487,15 @@ class SeqString : public String { ...@@ -487,6 +487,15 @@ class SeqString : public String {
DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString); DISALLOW_IMPLICIT_CONSTRUCTORS(SeqString);
}; };
class InternalizedString : public String {
public:
DECL_CAST(InternalizedString)
// TODO(neis): Possibly move some stuff from String here.
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(InternalizedString);
};
// The OneByteString class captures sequential one-byte string objects. // The OneByteString class captures sequential one-byte string objects.
// Each character in the OneByteString is an one-byte character. // Each character in the OneByteString is an one-byte character.
class SeqOneByteString : public SeqString { class SeqOneByteString : public SeqString {
......
...@@ -320,7 +320,7 @@ struct ObjectLiteralHelper { ...@@ -320,7 +320,7 @@ struct ObjectLiteralHelper {
static Handle<JSObject> Create(Isolate* isolate, static Handle<JSObject> Create(Isolate* isolate,
Handle<HeapObject> description, int flags, Handle<HeapObject> description, int flags,
PretenureFlag pretenure_flag) { PretenureFlag pretenure_flag) {
Handle<Context> native_context = isolate->native_context(); Handle<NativeContext> native_context = isolate->native_context();
Handle<ObjectBoilerplateDescription> object_boilerplate_description = Handle<ObjectBoilerplateDescription> object_boilerplate_description =
Handle<ObjectBoilerplateDescription>::cast(description); Handle<ObjectBoilerplateDescription>::cast(description);
bool use_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; bool use_fast_elements = (flags & ObjectLiteral::kFastElements) != 0;
......
...@@ -670,8 +670,8 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) { ...@@ -670,8 +670,8 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0);
Handle<Context> native_context(isolate->context(), isolate); Handle<NativeContext> native_context(NativeContext::cast(isolate->context()),
DCHECK(native_context->IsNativeContext()); isolate);
Handle<JSGlobalObject> global_object(native_context->global_object(), Handle<JSGlobalObject> global_object(native_context->global_object(),
isolate); isolate);
Handle<ScriptContextTable> script_context_table( Handle<ScriptContextTable> script_context_table(
...@@ -721,7 +721,7 @@ RUNTIME_FUNCTION(Runtime_PushModuleContext) { ...@@ -721,7 +721,7 @@ RUNTIME_FUNCTION(Runtime_PushModuleContext) {
CONVERT_ARG_HANDLE_CHECKED(Module, module, 0); CONVERT_ARG_HANDLE_CHECKED(Module, module, 0);
CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1);
Handle<Context> outer(isolate->context(), isolate); Handle<NativeContext> outer(NativeContext::cast(isolate->context()), isolate);
Handle<Context> context = Handle<Context> context =
isolate->factory()->NewModuleContext(module, outer, scope_info); isolate->factory()->NewModuleContext(module, outer, scope_info);
isolate->set_context(*context); isolate->set_context(*context);
......
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