Commit a330f15b authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[cleanup] Remove 'native' flag from ParseInfo

The native flag is a left-over from self-hosted JavaScript. Currently
only the empty function and empty script are marked native.
This CL removes the native flag from the ParseInfo,
UnoptimizedCompilationInfo and its handling in the bytecode generator.

R=leszeks@chromium.org

Bug: v8:8834,v8:9043
Change-Id: I60726e28ce83cc84249e9c49bdc88d81f0a695c9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545079Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60606}
parent 084207d9
......@@ -521,7 +521,7 @@ bool DeclarationScope::Analyze(ParseInfo* info) {
if (!scope->AllocateVariables(info)) return false;
#ifdef DEBUG
if (info->is_native() ? FLAG_print_builtin_scopes : FLAG_print_scopes) {
if (FLAG_print_scopes) {
PrintF("Global scope:\n");
scope->Print();
}
......@@ -1941,27 +1941,6 @@ void UpdateNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
} // anonymous namespace
void Scope::ResolveTo(ParseInfo* info, VariableProxy* proxy, Variable* var) {
#ifdef DEBUG
if (info->is_native()) {
// To avoid polluting the global object in native scripts
// - Variables must not be allocated to the global scope.
DCHECK_NOT_NULL(outer_scope());
// - Variables must be bound locally or unallocated.
if (var->IsGlobalObjectProperty()) {
// The following variable name may be minified. If so, disable
// minification in js2c.py for better output.
Handle<String> name = proxy->raw_name()->string();
FATAL("Unbound variable: '%s' in native script.",
name->ToCString().get());
}
VariableLocation location = var->location();
DCHECK(location == VariableLocation::LOCAL ||
location == VariableLocation::CONTEXT ||
location == VariableLocation::PARAMETER ||
location == VariableLocation::UNALLOCATED);
}
#endif
DCHECK_NOT_NULL(var);
UpdateNeedsHoleCheck(var, proxy, this);
proxy->BindTo(var);
......
......@@ -1367,8 +1367,7 @@ void BytecodeGenerator::VisitDeclarations(Declaration::List* declarations) {
globals_builder()->set_constant_pool_entry(
builder()->AllocateDeferredConstantPoolEntry());
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(info()->is_native());
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval());
// Emit code to declare globals.
RegisterList args = register_allocator()->NewRegisterList(3);
......
......@@ -231,7 +231,6 @@ void ParseInfo::set_script(Handle<Script> script) {
DCHECK(script_id_ == -1 || script_id_ == script->id());
script_id_ = script->id();
set_native(script->type() == Script::TYPE_NATIVE);
set_eval(script->compilation_type() == Script::COMPILATION_TYPE_EVAL);
set_module(script->origin_options().IsModule());
DCHECK(!(is_eval() && is_module()));
......
......@@ -73,7 +73,6 @@ class V8_EXPORT_PRIVATE ParseInfo {
FLAG_ACCESSOR(kEager, is_eager, set_eager)
FLAG_ACCESSOR(kEval, is_eval, set_eval)
FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode)
FLAG_ACCESSOR(kNative, is_native, set_native)
FLAG_ACCESSOR(kModule, is_module, set_module)
FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing)
FLAG_ACCESSOR(kIsNamedExpression, is_named_expression,
......
......@@ -420,9 +420,8 @@ Parser::Parser(ParseInfo* info)
? FunctionLiteral::kShouldLazyCompile
: FunctionLiteral::kShouldEagerCompile);
allow_lazy_ = info->allow_lazy_compile() && info->allow_lazy_parsing() &&
!info->is_native() && info->extension() == nullptr &&
can_compile_lazily;
set_allow_natives(info->allow_natives_syntax() || info->is_native());
info->extension() == nullptr && can_compile_lazily;
set_allow_natives(info->allow_natives_syntax());
set_allow_harmony_public_fields(info->allow_harmony_public_fields());
set_allow_harmony_static_fields(info->allow_harmony_static_fields());
set_allow_harmony_dynamic_import(info->allow_harmony_dynamic_import());
......
......@@ -184,10 +184,8 @@ Object DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
// Compute the property attributes. According to ECMA-262,
// the property must be non-configurable except in eval.
bool is_native = DeclareGlobalsNativeFlag::decode(flags);
bool is_eval = DeclareGlobalsEvalFlag::decode(flags);
int attr = NONE;
if (is_function && is_native) attr |= READ_ONLY;
if (!is_eval) attr |= DONT_DELETE;
// ES#sec-globaldeclarationinstantiation 5.d:
......
......@@ -768,7 +768,6 @@ V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, Runtime::FunctionId);
class AllocateDoubleAlignFlag : public BitField<bool, 0, 1> {};
class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
// A set of bits returned by Runtime_GetOptimizationStatus.
// These bits must be in sync with bits defined in test/mjsunit/mjsunit.js
......
......@@ -30,7 +30,6 @@ UnoptimizedCompilationInfo::UnoptimizedCompilationInfo(Zone* zone,
source_range_map_ = parse_info->source_range_map();
if (parse_info->is_eval()) MarkAsEval();
if (parse_info->is_native()) MarkAsNative();
if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
if (parse_info->might_always_opt()) MarkAsMightAlwaysOpt();
if (parse_info->collect_source_positions()) {
......@@ -53,11 +52,6 @@ int UnoptimizedCompilationInfo::num_parameters_including_this() const {
SourcePositionTableBuilder::RecordingMode
UnoptimizedCompilationInfo::SourcePositionRecordingMode() const {
if (is_native()) {
DCHECK(!collect_source_positions());
return SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS;
}
if (collect_source_positions()) {
return SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
}
......
......@@ -40,9 +40,6 @@ class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
void MarkAsEval() { SetFlag(kIsEval); }
bool is_eval() const { return GetFlag(kIsEval); }
void MarkAsNative() { SetFlag(kIsNative); }
bool is_native() const { return GetFlag(kIsNative); }
void MarkAsCollectTypeProfile() { SetFlag(kCollectTypeProfile); }
bool collect_type_profile() const { return GetFlag(kCollectTypeProfile); }
......@@ -104,10 +101,9 @@ class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
// of the compiled code produced by a compilation.
enum Flag {
kIsEval = 1 << 0,
kIsNative = 1 << 1,
kCollectTypeProfile = 1 << 2,
kMightAlwaysOpt = 1 << 3,
kCollectSourcePositions = 1 << 4,
kCollectTypeProfile = 1 << 1,
kMightAlwaysOpt = 1 << 2,
kCollectSourcePositions = 1 << 3,
};
void SetFlag(Flag flag) { flags_ |= flag; }
......
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