Chromium Code Reviews| Index: src/interpreter/bytecode-generator.cc |
| diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
| index 7279f69d8a01c554e1b0b627f423c994331568f8..d8359cf6be94d8c3a253c853f3bb1fdb3352c90c 100644 |
| --- a/src/interpreter/bytecode-generator.cc |
| +++ b/src/interpreter/bytecode-generator.cc |
| @@ -498,9 +498,10 @@ class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { |
| has_constant_pool_entry_(false) {} |
| void AddFunctionDeclaration(Handle<String> name, FeedbackVectorSlot slot, |
| + FeedbackVectorSlot literal_slot, |
| FunctionLiteral* func) { |
| DCHECK(!slot.IsInvalid()); |
| - declarations_.push_back(Declaration(name, slot, func)); |
| + declarations_.push_back(Declaration(name, slot, literal_slot, func)); |
| } |
| void AddUndefinedDeclaration(Handle<String> name, FeedbackVectorSlot slot) { |
| @@ -512,7 +513,7 @@ class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { |
| DCHECK(has_constant_pool_entry_); |
| int array_index = 0; |
| Handle<FixedArray> data = info->isolate()->factory()->NewFixedArray( |
| - static_cast<int>(declarations_.size() * 3), TENURED); |
| + static_cast<int>(declarations_.size() * 4), TENURED); |
| for (const Declaration& declaration : declarations_) { |
| FunctionLiteral* func = declaration.func; |
| Handle<Object> initial_value; |
| @@ -529,6 +530,12 @@ class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { |
| data->set(array_index++, *declaration.name); |
| data->set(array_index++, Smi::FromInt(declaration.slot.ToInt())); |
| + if (declaration.literal_slot.IsInvalid()) { |
|
Michael Starzinger
2017/01/17 12:48:21
nit: We could pull out the case distinction into a
mvstanton
2017/01/17 13:04:39
Good idea, thanks!
|
| + data->set(array_index++, info->isolate()->heap()->undefined_value()); |
| + } else { |
| + data->set(array_index++, |
| + Smi::FromInt(declaration.literal_slot.ToInt())); |
| + } |
| data->set(array_index++, *initial_value); |
| } |
| return data; |
| @@ -552,11 +559,15 @@ class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject { |
| struct Declaration { |
| Declaration() : slot(FeedbackVectorSlot::Invalid()), func(nullptr) {} |
| Declaration(Handle<String> name, FeedbackVectorSlot slot, |
| + FeedbackVectorSlot literal_slot, FunctionLiteral* func) |
| + : name(name), slot(slot), literal_slot(literal_slot), func(func) {} |
| + Declaration(Handle<String> name, FeedbackVectorSlot slot, |
| FunctionLiteral* func) |
| : name(name), slot(slot), func(func) {} |
|
Michael Starzinger
2017/01/17 12:48:21
nit: Let's explicitly initialize the {literal_slot
mvstanton
2017/01/17 13:04:39
Done.
|
| Handle<String> name; |
| FeedbackVectorSlot slot; |
| + FeedbackVectorSlot literal_slot; |
| FunctionLiteral* func; |
| }; |
| ZoneVector<Declaration> declarations_; |
| @@ -866,8 +877,9 @@ void BytecodeGenerator::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| switch (variable->location()) { |
| case VariableLocation::UNALLOCATED: { |
| FeedbackVectorSlot slot = decl->proxy()->VariableFeedbackSlot(); |
| - globals_builder()->AddFunctionDeclaration(variable->name(), slot, |
| - decl->fun()); |
| + globals_builder()->AddFunctionDeclaration( |
| + variable->name(), slot, decl->fun()->LiteralFeedbackSlot(), |
| + decl->fun()); |
| break; |
| } |
| case VariableLocation::PARAMETER: |