Commit 6786707f authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

Prefer type NativeContext over Context in more places

Change-Id: Ie0f54dd36a7af9503306d756182d98fc2273b48a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690828
Auto-Submit: Georg Neis <neis@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62558}
parent bda32bcb
......@@ -159,7 +159,7 @@ Code Deoptimizer::FindDeoptimizingCode(Address addr) {
if (function_.IsHeapObject()) {
// Search all deoptimizing code in the native context of the function.
Isolate* isolate = isolate_;
Context native_context = function_.context().native_context();
NativeContext native_context = function_.context().native_context();
Object element = native_context.DeoptimizedCodeListHead();
while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element);
......@@ -590,7 +590,7 @@ int Deoptimizer::GetDeoptimizedCodeCount(Isolate* isolate) {
// Count all entries in the deoptimizing code list of every context.
Object context = isolate->heap()->native_contexts_list();
while (!context.IsUndefined(isolate)) {
Context native_context = Context::cast(context);
NativeContext native_context = NativeContext::cast(context);
Object element = native_context.DeoptimizedCodeListHead();
while (!element.IsUndefined(isolate)) {
Code code = Code::cast(element);
......
......@@ -343,7 +343,7 @@ void Bootstrapper::LogAllMaps() {
void Bootstrapper::DetachGlobal(Handle<Context> env) {
isolate_->counters()->errors_thrown_per_context()->AddSample(
env->GetErrorsThrown());
env->native_context().GetErrorsThrown());
ReadOnlyRoots roots(isolate_);
Handle<JSGlobalProxy> global_proxy(env->global_proxy(), isolate_);
......
......@@ -352,7 +352,8 @@ bool Code::Inlines(SharedFunctionInfo sfi) {
Code::OptimizedCodeIterator::OptimizedCodeIterator(Isolate* isolate) {
isolate_ = isolate;
Object list = isolate->heap()->native_contexts_list();
next_context_ = list.IsUndefined(isolate_) ? Context() : Context::cast(list);
next_context_ =
list.IsUndefined(isolate_) ? NativeContext() : NativeContext::cast(list);
}
Code Code::OptimizedCodeIterator::Next() {
......@@ -366,8 +367,8 @@ Code Code::OptimizedCodeIterator::Next() {
next = next_context_.OptimizedCodeListHead();
Object next_context = next_context_.next_context_link();
next_context_ = next_context.IsUndefined(isolate_)
? Context()
: Context::cast(next_context);
? NativeContext()
: NativeContext::cast(next_context);
} else {
// Exhausted contexts.
return Code();
......
......@@ -476,7 +476,7 @@ class Code::OptimizedCodeIterator {
Code Next();
private:
Context next_context_;
NativeContext next_context_;
Code current_code_;
Isolate* isolate_;
......
......@@ -396,31 +396,26 @@ Handle<Object> Context::Lookup(Handle<Context> context, Handle<String> name,
return Handle<Object>::null();
}
void Context::AddOptimizedCode(Code code) {
DCHECK(IsNativeContext());
void NativeContext::AddOptimizedCode(Code code) {
DCHECK(code.kind() == Code::OPTIMIZED_FUNCTION);
DCHECK(code.next_code_link().IsUndefined());
code.set_next_code_link(get(OPTIMIZED_CODE_LIST));
set(OPTIMIZED_CODE_LIST, code, UPDATE_WEAK_WRITE_BARRIER);
}
void Context::SetOptimizedCodeListHead(Object head) {
DCHECK(IsNativeContext());
void NativeContext::SetOptimizedCodeListHead(Object head) {
set(OPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER);
}
Object Context::OptimizedCodeListHead() {
DCHECK(IsNativeContext());
Object NativeContext::OptimizedCodeListHead() {
return get(OPTIMIZED_CODE_LIST);
}
void Context::SetDeoptimizedCodeListHead(Object head) {
DCHECK(IsNativeContext());
void NativeContext::SetDeoptimizedCodeListHead(Object head) {
set(DEOPTIMIZED_CODE_LIST, head, UPDATE_WEAK_WRITE_BARRIER);
}
Object Context::DeoptimizedCodeListHead() {
DCHECK(IsNativeContext());
Object NativeContext::DeoptimizedCodeListHead() {
return get(DEOPTIMIZED_CODE_LIST);
}
......@@ -476,19 +471,14 @@ bool Context::IsBootstrappingOrValidParentContext(Object object,
#endif
void Context::ResetErrorsThrown() {
DCHECK(IsNativeContext());
set_errors_thrown(Smi::FromInt(0));
}
void Context::IncrementErrorsThrown() {
DCHECK(IsNativeContext());
void NativeContext::ResetErrorsThrown() { set_errors_thrown(Smi::FromInt(0)); }
void NativeContext::IncrementErrorsThrown() {
int previous_value = errors_thrown().value();
set_errors_thrown(Smi::FromInt(previous_value + 1));
}
int Context::GetErrorsThrown() { return errors_thrown().value(); }
int NativeContext::GetErrorsThrown() { return errors_thrown().value(); }
STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4);
STATIC_ASSERT(NativeContext::kScopeInfoOffset ==
......
......@@ -534,10 +534,6 @@ class Context : public HeapObject {
static const int kNoContext = 0;
static const int kInvalidContext = 1;
void ResetErrorsThrown();
void IncrementErrorsThrown();
int GetErrorsThrown();
// Direct slot access.
inline void set_scope_info(ScopeInfo scope_info);
......@@ -594,14 +590,6 @@ class Context : public HeapObject {
inline bool HasSameSecurityTokenAs(Context that) const;
// The native context also stores a list of all optimized code and a
// list of all deoptimized code, which are needed by the deoptimizer.
V8_EXPORT_PRIVATE void AddOptimizedCode(Code code);
void SetOptimizedCodeListHead(Object head);
Object OptimizedCodeListHead();
void SetDeoptimizedCodeListHead(Object head);
Object DeoptimizedCodeListHead();
Handle<Object> ErrorMessageForCodeGenerationFromStrings();
static int IntrinsicIndexForName(Handle<String> name);
......@@ -706,6 +694,18 @@ class NativeContext : public Context {
class BodyDescriptor;
// The native context stores a list of all optimized code and a list of all
// deoptimized code, which are needed by the deoptimizer.
V8_EXPORT_PRIVATE void AddOptimizedCode(Code code);
void SetOptimizedCodeListHead(Object head);
Object OptimizedCodeListHead();
void SetDeoptimizedCodeListHead(Object head);
Object DeoptimizedCodeListHead();
void ResetErrorsThrown();
void IncrementErrorsThrown();
int GetErrorsThrown();
private:
STATIC_ASSERT(OffsetOfElementAt(EMBEDDER_DATA_INDEX) ==
Internals::kNativeContextEmbedderDataOffset);
......
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