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}
This commit is contained in:
neis 2016-08-19 08:23:57 -07:00 committed by Commit bot
parent 20a8ef0b92
commit 9bc44ff086
4 changed files with 17 additions and 0 deletions

View File

@ -262,11 +262,17 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
}
} else if (context->IsScriptContext()) {
Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
current_scope = new (zone)
DeclarationScope(zone, current_scope, SCRIPT_SCOPE, scope_info);
} else if (context->IsFunctionContext()) {
Handle<ScopeInfo> scope_info(context->closure()->shared()->scope_info(),
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(zone, current_scope, FUNCTION_SCOPE, scope_info);
if (scope_info->IsAsmFunction()) function_scope->set_asm_function();
@ -274,6 +280,7 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
current_scope = function_scope;
} else if (context->IsBlockContext()) {
Handle<ScopeInfo> scope_info(context->scope_info(), isolate);
DCHECK_EQ(scope_info->scope_type(), BLOCK_SCOPE);
if (scope_info->is_declaration_scope()) {
current_scope = new (zone)
DeclarationScope(zone, current_scope, BLOCK_SCOPE, scope_info);

View File

@ -43,6 +43,7 @@ class Variable final : public ZoneObject {
return force_context_allocation_;
}
void ForceContextAllocation() {
DCHECK(IsUnallocated() || IsContextSlot());
force_context_allocation_ = true;
}
bool is_used() { return is_used_; }
@ -96,6 +97,7 @@ class Variable final : public ZoneObject {
}
void AllocateTo(VariableLocation location, int index) {
DCHECK(IsUnallocated() || (location_ == location && index_ == index));
location_ = location;
index_ = index;
}

View File

@ -760,6 +760,7 @@ Handle<Context> Factory::NewNativeContext() {
Handle<Context> Factory::NewScriptContext(Handle<JSFunction> function,
Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), SCRIPT_SCOPE);
Handle<FixedArray> array =
NewFixedArray(scope_info->ContextLength(), TENURED);
array->set_map_no_write_barrier(*script_context_map());
@ -784,6 +785,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() {
Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), MODULE_SCOPE);
Handle<FixedArray> array =
NewFixedArray(scope_info->ContextLength(), TENURED);
array->set_map_no_write_barrier(*module_context_map());
@ -796,6 +798,7 @@ Handle<Context> Factory::NewModuleContext(Handle<ScopeInfo> scope_info) {
Handle<Context> Factory::NewFunctionContext(int length,
Handle<JSFunction> function) {
DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
Handle<FixedArray> array = NewFixedArray(length);
array->set_map_no_write_barrier(*function_context_map());
@ -858,6 +861,7 @@ Handle<Context> Factory::NewWithContext(Handle<JSFunction> function,
Handle<Context> Factory::NewBlockContext(Handle<JSFunction> function,
Handle<Context> previous,
Handle<ScopeInfo> scope_info) {
DCHECK_EQ(scope_info->scope_type(), BLOCK_SCOPE);
Handle<FixedArray> array = NewFixedArray(scope_info->ContextLength());
array->set_map_no_write_barrier(*block_context_map());
Handle<Context> context = Handle<Context>::cast(array);

View File

@ -327,6 +327,10 @@
'built-ins/Function/prototype/toString/unicode': [FAIL],
# 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],
# https://bugs.chromium.org/p/v8/issues/detail?id=5012