[cleanup] Global variable declarations are never hole initialized
Globals used to be hole-initialized in the case of toplevel legacy const declarations. But now that the only use of legacy const is for sloppy function expression names, we can unconditionally initialize globals to undefined instead of the_hole. Review-Url: https://codereview.chromium.org/1964993002 Cr-Commit-Position: refs/heads/master@{#36151}
This commit is contained in:
parent
2d090ee46a
commit
bdf8dc4257
@ -1092,14 +1092,11 @@ void AstGraphBuilder::VisitVariableDeclaration(VariableDeclaration* decl) {
|
||||
bool hole_init = mode == CONST || mode == LET;
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED: {
|
||||
Handle<Oddball> value = variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value();
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals()->push_back(variable->name());
|
||||
globals()->push_back(value);
|
||||
globals()->push_back(isolate()->factory()->undefined_value());
|
||||
break;
|
||||
}
|
||||
case VariableLocation::PARAMETER:
|
||||
case VariableLocation::LOCAL:
|
||||
if (hole_init) {
|
||||
|
@ -12296,10 +12296,9 @@ void HOptimizedGraphBuilder::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_.Add(variable->name(), zone());
|
||||
globals_.Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(), zone());
|
||||
globals_.Add(isolate()->factory()->undefined_value(), zone());
|
||||
return;
|
||||
case VariableLocation::PARAMETER:
|
||||
case VariableLocation::LOCAL:
|
||||
|
@ -768,11 +768,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -765,11 +765,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -715,10 +715,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(), zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -765,11 +765,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -764,11 +764,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -730,11 +730,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -708,11 +708,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -727,11 +727,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(),
|
||||
zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -712,10 +712,9 @@ void FullCodeGenerator::VisitVariableDeclaration(
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals_->Add(variable->name(), zone());
|
||||
globals_->Add(variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value(), zone());
|
||||
globals_->Add(isolate()->factory()->undefined_value(), zone());
|
||||
break;
|
||||
|
||||
case VariableLocation::PARAMETER:
|
||||
|
@ -747,14 +747,11 @@ void BytecodeGenerator::VisitVariableDeclaration(VariableDeclaration* decl) {
|
||||
bool hole_init = mode == CONST || mode == LET;
|
||||
switch (variable->location()) {
|
||||
case VariableLocation::GLOBAL:
|
||||
case VariableLocation::UNALLOCATED: {
|
||||
Handle<Oddball> value = variable->binding_needs_init()
|
||||
? isolate()->factory()->the_hole_value()
|
||||
: isolate()->factory()->undefined_value();
|
||||
case VariableLocation::UNALLOCATED:
|
||||
DCHECK(!variable->binding_needs_init());
|
||||
globals()->push_back(variable->name());
|
||||
globals()->push_back(value);
|
||||
globals()->push_back(isolate()->factory()->undefined_value());
|
||||
break;
|
||||
}
|
||||
case VariableLocation::LOCAL:
|
||||
if (hole_init) {
|
||||
Register destination(variable->index());
|
||||
|
Loading…
Reference in New Issue
Block a user