Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 1422443006: [Intepreter] Don't throw reference errors for globals in typeof. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index fdc61d2f3c1cad5cd2ae359654ba295f079b8158..03db4e184d754329f18a1936b2f62313c647d9e1 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1193,7 +1193,8 @@ void BytecodeGenerator::VisitVariableProxy(VariableProxy* proxy) {
void BytecodeGenerator::VisitVariableLoad(Variable* variable,
- FeedbackVectorSlot slot) {
+ FeedbackVectorSlot slot,
+ TypeofMode typeof_mode) {
switch (variable->location()) {
case VariableLocation::LOCAL: {
Register source(Register(variable->index()));
@@ -1210,7 +1211,8 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
case VariableLocation::GLOBAL:
case VariableLocation::UNALLOCATED: {
size_t name_index = builder()->GetConstantPoolEntry(variable->name());
- builder()->LoadGlobal(name_index, feedback_index(slot), language_mode());
+ builder()->LoadGlobal(name_index, feedback_index(slot), language_mode(),
+ typeof_mode);
execution_result()->SetResultInAccumulator();
break;
}
@@ -1247,16 +1249,16 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
void BytecodeGenerator::VisitVariableLoadForAccumulatorValue(
- Variable* variable, FeedbackVectorSlot slot) {
+ Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) {
AccumulatorResultScope accumulator_result(this);
- VisitVariableLoad(variable, slot);
+ VisitVariableLoad(variable, slot, typeof_mode);
}
Register BytecodeGenerator::VisitVariableLoadForRegisterValue(
- Variable* variable, FeedbackVectorSlot slot) {
+ Variable* variable, FeedbackVectorSlot slot, TypeofMode typeof_mode) {
RegisterResultScope register_scope(this);
- VisitVariableLoad(variable, slot);
+ VisitVariableLoad(variable, slot, typeof_mode);
return register_scope.ResultRegister();
}
@@ -1616,9 +1618,15 @@ void BytecodeGenerator::VisitVoid(UnaryOperation* expr) {
void BytecodeGenerator::VisitTypeOf(UnaryOperation* expr) {
- // TODO(rmcilroy): Set TypeofMode to INSIDE_TYPEOF for any loadICs performed
- // while visiting the expression.
- VisitForAccumulatorValue(expr->expression());
+ if (expr->expression()->IsVariableProxy()) {
+ // Typeof does not throw a reference error on global variables, hence we
+ // perform a non-contextual load in case the operand is a variable proxy.
+ VariableProxy* proxy = expr->expression()->AsVariableProxy();
+ VisitVariableLoadForAccumulatorValue(
+ proxy->var(), proxy->VariableFeedbackSlot(), INSIDE_TYPEOF);
+ } else {
+ VisitForAccumulatorValue(expr->expression());
+ }
builder()->TypeOf();
execution_result()->SetResultInAccumulator();
}
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698