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

Prefer NativeContext type over the less precise Context

Change-Id: I9285052dfe21df8e0eaf0e0493458532f82504ae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687421Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Auto-Submit: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62546}
parent 648af01c
...@@ -214,7 +214,7 @@ bool OptimizedCompilationInfo::has_native_context() const { ...@@ -214,7 +214,7 @@ bool OptimizedCompilationInfo::has_native_context() const {
return !closure().is_null() && !closure()->native_context().is_null(); return !closure().is_null() && !closure()->native_context().is_null();
} }
Context OptimizedCompilationInfo::native_context() const { NativeContext OptimizedCompilationInfo::native_context() const {
DCHECK(has_native_context()); DCHECK(has_native_context());
return closure()->native_context(); return closure()->native_context();
} }
......
...@@ -212,7 +212,7 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final { ...@@ -212,7 +212,7 @@ class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
Context context() const; Context context() const;
bool has_native_context() const; bool has_native_context() const;
Context native_context() const; NativeContext native_context() const;
bool has_global_object() const; bool has_global_object() const;
JSGlobalObject global_object() const; JSGlobalObject global_object() const;
......
...@@ -39,7 +39,7 @@ class BytecodeGraphBuilder { ...@@ -39,7 +39,7 @@ class BytecodeGraphBuilder {
BailoutId osr_offset, JSGraph* jsgraph, BailoutId osr_offset, JSGraph* jsgraph,
CallFrequency const& invocation_frequency, CallFrequency const& invocation_frequency,
SourcePositionTable* source_positions, SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id, Handle<NativeContext> native_context, int inlining_id,
BytecodeGraphBuilderFlags flags); BytecodeGraphBuilderFlags flags);
// Creates a graph by visiting bytecodes. // Creates a graph by visiting bytecodes.
...@@ -369,7 +369,7 @@ class BytecodeGraphBuilder { ...@@ -369,7 +369,7 @@ class BytecodeGraphBuilder {
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
Handle<Context> native_context() const { return native_context_; } Handle<NativeContext> native_context() const { return native_context_; }
JSHeapBroker* broker() const { return broker_; } JSHeapBroker* broker() const { return broker_; }
...@@ -436,7 +436,7 @@ class BytecodeGraphBuilder { ...@@ -436,7 +436,7 @@ class BytecodeGraphBuilder {
Handle<SharedFunctionInfo> const shared_info_; Handle<SharedFunctionInfo> const shared_info_;
// The native context for which we optimize. // The native context for which we optimize.
Handle<Context> const native_context_; Handle<NativeContext> const native_context_;
static int const kBinaryOperationHintIndex = 1; static int const kBinaryOperationHintIndex = 1;
static int const kCountOperationHintIndex = 0; static int const kCountOperationHintIndex = 0;
...@@ -941,7 +941,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder( ...@@ -941,7 +941,7 @@ BytecodeGraphBuilder::BytecodeGraphBuilder(
Handle<SharedFunctionInfo> shared_info, Handle<SharedFunctionInfo> shared_info,
Handle<FeedbackVector> feedback_vector, BailoutId osr_offset, Handle<FeedbackVector> feedback_vector, BailoutId osr_offset,
JSGraph* jsgraph, CallFrequency const& invocation_frequency, JSGraph* jsgraph, CallFrequency const& invocation_frequency,
SourcePositionTable* source_positions, Handle<Context> native_context, SourcePositionTable* source_positions, Handle<NativeContext> native_context,
int inlining_id, BytecodeGraphBuilderFlags flags) int inlining_id, BytecodeGraphBuilderFlags flags)
: broker_(broker), : broker_(broker),
local_zone_(local_zone), local_zone_(local_zone),
...@@ -4020,8 +4020,8 @@ void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone, ...@@ -4020,8 +4020,8 @@ void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone,
BailoutId osr_offset, JSGraph* jsgraph, BailoutId osr_offset, JSGraph* jsgraph,
CallFrequency const& invocation_frequency, CallFrequency const& invocation_frequency,
SourcePositionTable* source_positions, SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id, Handle<NativeContext> native_context,
BytecodeGraphBuilderFlags flags) { int inlining_id, BytecodeGraphBuilderFlags flags) {
BytecodeArrayRef bytecode_array_ref(broker, bytecode_array); BytecodeArrayRef bytecode_array_ref(broker, bytecode_array);
DCHECK(bytecode_array_ref.IsSerializedForCompilation()); DCHECK(bytecode_array_ref.IsSerializedForCompilation());
BytecodeGraphBuilder builder(broker, local_zone, bytecode_array_ref, shared, BytecodeGraphBuilder builder(broker, local_zone, bytecode_array_ref, shared,
......
...@@ -39,8 +39,8 @@ void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone, ...@@ -39,8 +39,8 @@ void BuildGraphFromBytecode(JSHeapBroker* broker, Zone* local_zone,
BailoutId osr_offset, JSGraph* jsgraph, BailoutId osr_offset, JSGraph* jsgraph,
CallFrequency const& invocation_frequency, CallFrequency const& invocation_frequency,
SourcePositionTable* source_positions, SourcePositionTable* source_positions,
Handle<Context> native_context, int inlining_id, Handle<NativeContext> native_context,
BytecodeGraphBuilderFlags flags); int inlining_id, BytecodeGraphBuilderFlags flags);
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
......
...@@ -468,9 +468,7 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -468,9 +468,7 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
AllowHeapAllocation allow_heap_alloc; AllowHeapAllocation allow_heap_alloc;
AllowCodeDependencyChange allow_code_dep_change; AllowCodeDependencyChange allow_code_dep_change;
CallFrequency frequency = call.frequency(); CallFrequency frequency = call.frequency();
Handle<Context> native_context = Handle<NativeContext> native_context(info_->native_context(), isolate());
handle(info_->native_context(), isolate());
BuildGraphFromBytecode(broker(), zone(), bytecode_array.object(), BuildGraphFromBytecode(broker(), zone(), bytecode_array.object(),
shared_info.value().object(), shared_info.value().object(),
feedback_vector.object(), BailoutId::None(), feedback_vector.object(), BailoutId::None(),
......
...@@ -268,7 +268,7 @@ class PipelineData { ...@@ -268,7 +268,7 @@ class PipelineData {
JSOperatorBuilder* javascript() const { return javascript_; } JSOperatorBuilder* javascript() const { return javascript_; }
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
MachineGraph* mcgraph() const { return mcgraph_; } MachineGraph* mcgraph() const { return mcgraph_; }
Handle<Context> native_context() const { Handle<NativeContext> native_context() const {
return handle(info()->native_context(), isolate()); return handle(info()->native_context(), isolate());
} }
Handle<JSGlobalObject> global_object() const { Handle<JSGlobalObject> global_object() const {
......
...@@ -270,10 +270,10 @@ class ActivationsFinder : public ThreadVisitor { ...@@ -270,10 +270,10 @@ class ActivationsFinder : public ThreadVisitor {
// Move marked code from the optimized code list to the deoptimized code list, // Move marked code from the optimized code list to the deoptimized code list,
// and replace pc on the stack for codes marked for deoptimization. // and replace pc on the stack for codes marked for deoptimization.
void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) { void Deoptimizer::DeoptimizeMarkedCodeForContext(NativeContext native_context) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
Isolate* isolate = context.GetIsolate(); Isolate* isolate = native_context.GetIsolate();
Code topmost_optimized_code; Code topmost_optimized_code;
bool safe_to_deopt_topmost_optimized_code = false; bool safe_to_deopt_topmost_optimized_code = false;
#ifdef DEBUG #ifdef DEBUG
...@@ -315,7 +315,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) { ...@@ -315,7 +315,7 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) {
// Move marked code from the optimized code list to the deoptimized code list. // Move marked code from the optimized code list to the deoptimized code list.
// Walk over all optimized code objects in this native context. // Walk over all optimized code objects in this native context.
Code prev; Code prev;
Object element = context.OptimizedCodeListHead(); Object element = native_context.OptimizedCodeListHead();
while (!element.IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION); CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION);
...@@ -329,12 +329,12 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) { ...@@ -329,12 +329,12 @@ void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) {
prev.set_next_code_link(next); prev.set_next_code_link(next);
} else { } else {
// There was no previous node, the next node is the new head. // There was no previous node, the next node is the new head.
context.SetOptimizedCodeListHead(next); native_context.SetOptimizedCodeListHead(next);
} }
// Move the code to the _deoptimized_ code list. // Move the code to the _deoptimized_ code list.
code.set_next_code_link(context.DeoptimizedCodeListHead()); code.set_next_code_link(native_context.DeoptimizedCodeListHead());
context.SetDeoptimizedCodeListHead(code); native_context.SetDeoptimizedCodeListHead(code);
} else { } else {
// Not marked; preserve this element. // Not marked; preserve this element.
prev = code; prev = code;
...@@ -373,7 +373,7 @@ void Deoptimizer::DeoptimizeAll(Isolate* isolate) { ...@@ -373,7 +373,7 @@ void Deoptimizer::DeoptimizeAll(Isolate* isolate) {
// For all contexts, mark all code, then deoptimize. // For all contexts, mark all code, then deoptimize.
Object context = isolate->heap()->native_contexts_list(); Object context = isolate->heap()->native_contexts_list();
while (!context.IsUndefined(isolate)) { while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context); NativeContext native_context = NativeContext::cast(context);
MarkAllCodeForContext(native_context); MarkAllCodeForContext(native_context);
DeoptimizeMarkedCodeForContext(native_context); DeoptimizeMarkedCodeForContext(native_context);
context = native_context.next_context_link(); context = native_context.next_context_link();
...@@ -393,15 +393,15 @@ void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) { ...@@ -393,15 +393,15 @@ void Deoptimizer::DeoptimizeMarkedCode(Isolate* isolate) {
// For all contexts, deoptimize code already marked. // For all contexts, deoptimize code already marked.
Object context = isolate->heap()->native_contexts_list(); Object context = isolate->heap()->native_contexts_list();
while (!context.IsUndefined(isolate)) { while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context); NativeContext native_context = NativeContext::cast(context);
DeoptimizeMarkedCodeForContext(native_context); DeoptimizeMarkedCodeForContext(native_context);
context = native_context.next_context_link(); context = native_context.next_context_link();
} }
} }
void Deoptimizer::MarkAllCodeForContext(Context context) { void Deoptimizer::MarkAllCodeForContext(NativeContext native_context) {
Object element = context.OptimizedCodeListHead(); Object element = native_context.OptimizedCodeListHead();
Isolate* isolate = context.GetIsolate(); Isolate* isolate = native_context.GetIsolate();
while (!element.IsUndefined(isolate)) { while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element); Code code = Code::cast(element);
CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION); CHECK_EQ(code.kind(), Code::OPTIMIZED_FUNCTION);
......
...@@ -550,11 +550,8 @@ class Deoptimizer : public Malloced { ...@@ -550,11 +550,8 @@ class Deoptimizer : public Malloced {
Isolate* isolate, Isolate* isolate,
DeoptimizeKind kind); DeoptimizeKind kind);
// Marks all the code in the given context for deoptimization. static void MarkAllCodeForContext(NativeContext native_context);
static void MarkAllCodeForContext(Context native_context); static void DeoptimizeMarkedCodeForContext(NativeContext native_context);
// Deoptimizes all code marked in the given context.
static void DeoptimizeMarkedCodeForContext(Context native_context);
// Some architectures need to push padding together with the TOS register // Some architectures need to push padding together with the TOS register
// in order to maintain stack alignment. // in order to maintain stack alignment.
......
...@@ -16,11 +16,9 @@ namespace internal { ...@@ -16,11 +16,9 @@ namespace internal {
// static // static
Handle<JSArray> TemplateObjectDescription::GetTemplateObject( Handle<JSArray> TemplateObjectDescription::GetTemplateObject(
Isolate* isolate, Handle<Context> native_context, Isolate* isolate, Handle<NativeContext> native_context,
Handle<TemplateObjectDescription> description, Handle<TemplateObjectDescription> description,
Handle<SharedFunctionInfo> shared_info, int slot_id) { Handle<SharedFunctionInfo> shared_info, int slot_id) {
DCHECK(native_context->IsNativeContext());
// Check the template weakmap to see if the template object already exists. // Check the template weakmap to see if the template object already exists.
Handle<EphemeronHashTable> template_weakmap = Handle<EphemeronHashTable> template_weakmap =
native_context->template_weakmap().IsUndefined(isolate) native_context->template_weakmap().IsUndefined(isolate)
......
...@@ -47,7 +47,7 @@ class TemplateObjectDescription final : public Struct { ...@@ -47,7 +47,7 @@ class TemplateObjectDescription final : public Struct {
DECL_CAST(TemplateObjectDescription) DECL_CAST(TemplateObjectDescription)
static Handle<JSArray> GetTemplateObject( static Handle<JSArray> GetTemplateObject(
Isolate* isolate, Handle<Context> native_context, Isolate* isolate, Handle<NativeContext> native_context,
Handle<TemplateObjectDescription> description, Handle<TemplateObjectDescription> description,
Handle<SharedFunctionInfo> shared_info, int slot_id); Handle<SharedFunctionInfo> shared_info, int slot_id);
......
...@@ -695,7 +695,8 @@ RUNTIME_FUNCTION(Runtime_GetTemplateObject) { ...@@ -695,7 +695,8 @@ RUNTIME_FUNCTION(Runtime_GetTemplateObject) {
CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared_info, 1); CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared_info, 1);
CONVERT_SMI_ARG_CHECKED(slot_id, 2); CONVERT_SMI_ARG_CHECKED(slot_id, 2);
Handle<Context> native_context(isolate->context().native_context(), isolate); Handle<NativeContext> native_context(isolate->context().native_context(),
isolate);
return *TemplateObjectDescription::GetTemplateObject( return *TemplateObjectDescription::GetTemplateObject(
isolate, native_context, description, shared_info, slot_id); isolate, native_context, description, shared_info, slot_id);
} }
......
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