Commit ee8e1464 authored by neis's avatar neis Committed by Commit bot

Check some more invariants on SFIs.

This adds consistency checks for function kind and scope type to
SharedFunctionInfoVerify.

It also fixes an inconsistency in the creation of a ScopeInfo.

R=adamk@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2537093002
Cr-Commit-Position: refs/heads/master@{#41375}
parent 881bacff
......@@ -143,13 +143,15 @@ Handle<ScopeInfo> ScopeInfo::Create(Isolate* isolate, Zone* zone, Scope* scope,
bool has_simple_parameters = false;
bool asm_module = false;
bool asm_function = false;
FunctionKind function_kind = kNormalFunction;
if (scope->is_function_scope()) {
DeclarationScope* function_scope = scope->AsDeclarationScope();
has_simple_parameters = function_scope->has_simple_parameters();
asm_module = function_scope->asm_module();
asm_function = function_scope->asm_function();
function_kind = function_scope->function_kind();
}
FunctionKind function_kind = kNormalFunction;
if (scope->is_declaration_scope()) {
function_kind = scope->AsDeclarationScope()->function_kind();
}
// Encode the flags.
......
......@@ -604,21 +604,29 @@ void JSFunction::JSFunctionVerify() {
void SharedFunctionInfo::SharedFunctionInfoVerify() {
CHECK(IsSharedFunctionInfo());
VerifyObjectField(kNameOffset);
VerifyObjectField(kCodeOffset);
VerifyObjectField(kOptimizedCodeMapOffset);
VerifyObjectField(kDebugInfoOffset);
VerifyObjectField(kFeedbackMetadataOffset);
VerifyObjectField(kScopeInfoOffset);
VerifyObjectField(kOuterScopeInfoOffset);
VerifyObjectField(kFunctionDataOffset);
VerifyObjectField(kFunctionIdentifierOffset);
VerifyObjectField(kInstanceClassNameOffset);
VerifyObjectField(kNameOffset);
VerifyObjectField(kOptimizedCodeMapOffset);
VerifyObjectField(kOuterScopeInfoOffset);
VerifyObjectField(kScopeInfoOffset);
VerifyObjectField(kScriptOffset);
CHECK(function_data()->IsUndefined(GetIsolate()) || IsApiFunction() ||
HasBytecodeArray() || HasAsmWasmData());
VerifyObjectField(kFunctionDataOffset);
VerifyObjectField(kScriptOffset);
VerifyObjectField(kDebugInfoOffset);
CHECK(function_identifier()->IsUndefined(GetIsolate()) ||
HasBuiltinFunctionId() || HasInferredName());
VerifyObjectField(kFunctionIdentifierOffset);
if (scope_info()->length() > 0) {
CHECK(kind() == scope_info()->function_kind());
CHECK_EQ(kind() == kModule, scope_info()->scope_type() == MODULE_SCOPE);
}
}
......
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