OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-register-allocator.h" | 10 #include "src/interpreter/bytecode-register-allocator.h" |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 builder()->Debugger(); | 1293 builder()->Debugger(); |
1294 } | 1294 } |
1295 | 1295 |
1296 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { | 1296 void BytecodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
1297 // Find or build a shared function info. | 1297 // Find or build a shared function info. |
1298 Handle<SharedFunctionInfo> shared_info = | 1298 Handle<SharedFunctionInfo> shared_info = |
1299 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); | 1299 Compiler::GetSharedFunctionInfo(expr, info()->script(), info()); |
1300 if (shared_info.is_null()) { | 1300 if (shared_info.is_null()) { |
1301 return SetStackOverflow(); | 1301 return SetStackOverflow(); |
1302 } | 1302 } |
1303 builder()->CreateClosure(shared_info, | 1303 uint8_t flags = CreateClosureFlags::Encode(expr->pretenure(), |
1304 expr->pretenure() ? TENURED : NOT_TENURED); | 1304 scope()->is_function_scope()); |
| 1305 builder()->CreateClosure(shared_info, flags); |
1305 execution_result()->SetResultInAccumulator(); | 1306 execution_result()->SetResultInAccumulator(); |
1306 } | 1307 } |
1307 | 1308 |
1308 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { | 1309 void BytecodeGenerator::VisitClassLiteral(ClassLiteral* expr) { |
1309 if (expr->scope()->ContextLocalCount() > 0) { | 1310 if (expr->scope()->ContextLocalCount() > 0) { |
1310 VisitNewLocalBlockContext(expr->scope()); | 1311 VisitNewLocalBlockContext(expr->scope()); |
1311 ContextScope scope(this, expr->scope()); | 1312 ContextScope scope(this, expr->scope()); |
1312 VisitDeclarations(expr->scope()->declarations()); | 1313 VisitDeclarations(expr->scope()->declarations()); |
1313 VisitClassLiteralContents(expr); | 1314 VisitClassLiteralContents(expr); |
1314 } else { | 1315 } else { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 | 1512 |
1512 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1513 void BytecodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1513 // Materialize a regular expression literal. | 1514 // Materialize a regular expression literal. |
1514 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), | 1515 builder()->CreateRegExpLiteral(expr->pattern(), expr->literal_index(), |
1515 expr->flags()); | 1516 expr->flags()); |
1516 execution_result()->SetResultInAccumulator(); | 1517 execution_result()->SetResultInAccumulator(); |
1517 } | 1518 } |
1518 | 1519 |
1519 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1520 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
1520 // Copy the literal boilerplate. | 1521 // Copy the literal boilerplate. |
1521 int fast_clone_properties_count = 0; | 1522 uint8_t flags = CreateObjectLiteralFlags::Encode( |
1522 if (FastCloneShallowObjectStub::IsSupported(expr)) { | 1523 FastCloneShallowObjectStub::IsSupported(expr), |
1523 STATIC_ASSERT( | 1524 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()), |
1524 FastCloneShallowObjectStub::kMaximumClonedProperties <= | 1525 expr->ComputeFlags()); |
1525 1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift); | |
1526 fast_clone_properties_count = | |
1527 FastCloneShallowObjectStub::PropertiesCount(expr->properties_count()); | |
1528 } | |
1529 uint8_t flags = | |
1530 CreateObjectLiteralFlags::FlagsBits::encode(expr->ComputeFlags()) | | |
1531 CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode( | |
1532 fast_clone_properties_count); | |
1533 builder()->CreateObjectLiteral(expr->constant_properties(), | 1526 builder()->CreateObjectLiteral(expr->constant_properties(), |
1534 expr->literal_index(), flags); | 1527 expr->literal_index(), flags); |
1535 | 1528 |
1536 // Allocate in the outer scope since this register is used to return the | 1529 // Allocate in the outer scope since this register is used to return the |
1537 // expression's results to the caller. | 1530 // expression's results to the caller. |
1538 Register literal = register_allocator()->outer()->NewRegister(); | 1531 Register literal = register_allocator()->outer()->NewRegister(); |
1539 builder()->StoreAccumulatorInRegister(literal); | 1532 builder()->StoreAccumulatorInRegister(literal); |
1540 | 1533 |
1541 // Store computed values into the literal. | 1534 // Store computed values into the literal. |
1542 int property_index = 0; | 1535 int property_index = 0; |
(...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3174 return execution_context()->scope()->language_mode(); | 3167 return execution_context()->scope()->language_mode(); |
3175 } | 3168 } |
3176 | 3169 |
3177 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3170 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3178 return TypeFeedbackVector::GetIndex(slot); | 3171 return TypeFeedbackVector::GetIndex(slot); |
3179 } | 3172 } |
3180 | 3173 |
3181 } // namespace interpreter | 3174 } // namespace interpreter |
3182 } // namespace internal | 3175 } // namespace internal |
3183 } // namespace v8 | 3176 } // namespace v8 |
OLD | NEW |