Commit 9bc44ff0 authored by neis's avatar neis Committed by Commit bot

Add some scope-related DCHECKs.

R=adamk@chromium.org, verwaest@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2263523002
Cr-Commit-Position: refs/heads/master@{#38755}
parent 20a8ef0b
...@@ -262,11 +262,17 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, ...@@ -262,11 +262,17 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
} }
} else if (context->IsScriptContext()) { } else if (context->IsScriptContext()) {
Handle<ScopeInfo> scope_info(context->scope_info(), isolate); Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
current_scope = new (zone) current_scope = new (zone)
DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info); DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info);
} else if (context->IsFunctionContext()) { } else if (context->IsFunctionContext()) {
Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(), Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(),
isolate); isolate);
// TODO(neis): For an eval scope, we currently create an ordinary function
// context. This is wrong and needs to be fixed.
// https://bugs.chromium.org/p/v8/issues/detail?id=5295
DCHECK(scope_info->scope_type() == FUNCTION_SCOPE ||
scope_info->scope_type() == EVAL_SCOPE);
DeclarationScope* function_scope = new (zone) DeclarationScope* function_scope = new (zone)
DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info); DeclarationScope(zone, current_scope, FUNCTION_SCOPE, scope_info);
if (scope_info->IsAsmFunction()) function_scope->set_asm_function(); if (scope_info->IsAsmFunction()) function_scope->set_asm_function();
...@@ -274,6 +280,7 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, ...@@ -274,6 +280,7 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
current_scope = function_scope; current_scope = function_scope;
} else if (context->IsBlockContext()) { } else if (context->IsBlockContext()) {
Handle<ScopeInfo> scope_info(context->scope_info(), isolate); Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
DCHECK_EQ(scope_info->scope_type(), BLOCK_SCOPE);
if (scope_info->is_declaration_scope()) { if (scope_info->is_declaration_scope()) {
current_scope = new (zone) current_scope = new (zone)
DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info); DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info);
......
...@@ -43,6 +43,7 @@ class Variable final : public ZoneObject { ...@@ -43,6 +43,7 @@ class Variable final : public ZoneObject {
return force_context_allocation_; return force_context_allocation_;
} }
void ForceContextAllocation() { void ForceContextAllocation() {
DCHECK(IsUnallocated() || IsContextSlot());
force_context_allocation_ = true; force_context_allocation_ = true;
} }
bool is_used() { return is_used_; } bool is_used() { return is_used_; }
...@@ -96,6 +97,7 @@ class Variable final : public ZoneObject { ...@@ -96,6 +97,7 @@ class Variable final : public ZoneObject {
} }
void AllocateTo(VariableLocation location, int index) { void AllocateTo(VariableLocation location, int index) {
DCHECK(IsUnallocated() || (location_ == location && index_ == index));
location_ = location; location_ = location;
index_ = index; index_ = index;
} }
......
...@@ -760,6 +760,7 @@ Handle<Context> Factory::NewNativeContext() { ...@@ -760,6 +760,7 @@ Handle<Context> Factory::NewNativeContext() {
Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function, Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function,
Handle<ScopeInfo> scope_info) { Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
Handle<FixedArray> array = Handle<FixedArray> array =
NewFixedArray(scope_info->ContextLength(), TENURED); NewFixedArray(scope_info->ContextLength(), TENURED);
array->set_map_no_write_barrier(*script_context_map()); array->set_map_no_write_barrier(*script_context_map());
...@@ -784,6 +785,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() { ...@@ -784,6 +785,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() {
Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
Handle<FixedArray> array = Handle<FixedArray> array =
NewFixedArray(scope_info->ContextLength(), TENURED); NewFixedArray(scope_info->ContextLength(), TENURED);
array->set_map_no_write_barrier(*module_context_map()); array->set_map_no_write_barrier(*module_context_map());
...@@ -796,6 +798,7 @@ Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) { ...@@ -796,6 +798,7 @@ Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
Handle<Context> Factory::NewFunctionContext(int length, Handle<Context> Factory::NewFunctionContext(int length,
Handle<JSFunction> function) { Handle<JSFunction> function) {
DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
DCHECK(length >= Context::MIN_CONTEXT_SLOTS); DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
Handle<FixedArray> array = NewFixedArray(length); Handle<FixedArray> array = NewFixedArray(length);
array->set_map_no_write_barrier(*function_context_map()); array->set_map_no_write_barrier(*function_context_map());
...@@ -858,6 +861,7 @@ Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, ...@@ -858,6 +861,7 @@ Handle<Context> Factory::NewWithContext(Handle<JSFunction> function,
Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function, Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function,
Handle<Context> previous, Handle<Context> previous,
Handle<ScopeInfo> scope_info) { Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), BLOCK_SCOPE);
Handle<FixedArray> array = NewFixedArray(scope_info->ContextLength()); Handle<FixedArray> array = NewFixedArray(scope_info->ContextLength());
array->set_map_no_write_barrier(*block_context_map()); array->set_map_no_write_barrier(*block_context_map());
Handle<Context> context = Handle<Context>::cast(array); Handle<Context> context = Handle<Context>::cast(array);
......
...@@ -327,6 +327,10 @@ ...@@ -327,6 +327,10 @@
'built-ins/Function/prototype/toString/unicode': [FAIL], 'built-ins/Function/prototype/toString/unicode': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=1569 # https://bugs.chromium.org/p/v8/issues/detail?id=1569
'language/eval-code/direct/export': [SKIP],
'language/eval-code/direct/import': [SKIP],
'language/eval-code/indirect/export': [SKIP],
'language/eval-code/indirect/import': [SKIP],
'language/module-code/*': [SKIP], 'language/module-code/*': [SKIP],
# https://bugs.chromium.org/p/v8/issues/detail?id=5012 # https://bugs.chromium.org/p/v8/issues/detail?id=5012
......
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