OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 Handle<SharedFunctionInfo> function_info = | 1460 Handle<SharedFunctionInfo> function_info = |
1461 Compiler::GetSharedFunctionInfo(expr, script(), info_); | 1461 Compiler::GetSharedFunctionInfo(expr, script(), info_); |
1462 if (function_info.is_null()) { | 1462 if (function_info.is_null()) { |
1463 SetStackOverflow(); | 1463 SetStackOverflow(); |
1464 return; | 1464 return; |
1465 } | 1465 } |
1466 EmitNewClosure(function_info, expr->pretenure()); | 1466 EmitNewClosure(function_info, expr->pretenure()); |
1467 } | 1467 } |
1468 | 1468 |
1469 | 1469 |
1470 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { | |
1471 Comment cmnt(masm_, "[ ClassLiteral"); | |
1472 | |
1473 { | |
1474 NestedClassLiteral nested_class_literal(this, lit); | |
1475 EnterBlockScopeIfNeeded block_scope_state( | |
1476 this, lit->scope(), lit->EntryId(), lit->DeclsId(), lit->ExitId()); | |
1477 | |
1478 if (lit->extends() != NULL) { | |
1479 VisitForStackValue(lit->extends()); | |
1480 } else { | |
1481 PushOperand(isolate()->factory()->the_hole_value()); | |
1482 } | |
1483 | |
1484 VisitForStackValue(lit->constructor()); | |
1485 | |
1486 PushOperand(Smi::FromInt(lit->start_position())); | |
1487 PushOperand(Smi::FromInt(lit->end_position())); | |
1488 | |
1489 CallRuntimeWithOperands(Runtime::kDefineClass); | |
1490 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER); | |
1491 PushOperand(result_register()); | |
1492 | |
1493 // Load the "prototype" from the constructor. | |
1494 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); | |
1495 __ LoadRoot(LoadDescriptor::NameRegister(), | |
1496 Heap::kprototype_stringRootIndex); | |
1497 __ Move(LoadDescriptor::SlotRegister(), SmiFromSlot(lit->PrototypeSlot())); | |
1498 CallLoadIC(); | |
1499 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER); | |
1500 PushOperand(result_register()); | |
1501 | |
1502 EmitClassDefineProperties(lit); | |
1503 DropOperands(1); | |
1504 | |
1505 // Set the constructor to have fast properties. | |
1506 CallRuntimeWithOperands(Runtime::kToFastProperties); | |
1507 | |
1508 if (lit->class_variable_proxy() != nullptr) { | |
1509 EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT, | |
1510 lit->ProxySlot()); | |
1511 } | |
1512 } | |
1513 | |
1514 context()->Plug(result_register()); | |
1515 } | |
1516 | |
1517 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1470 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1518 Comment cmnt(masm_, "[ RegExpLiteral"); | 1471 Comment cmnt(masm_, "[ RegExpLiteral"); |
1519 Callable callable = CodeFactory::FastCloneRegExp(isolate()); | 1472 Callable callable = CodeFactory::FastCloneRegExp(isolate()); |
1520 CallInterfaceDescriptor descriptor = callable.descriptor(); | 1473 CallInterfaceDescriptor descriptor = callable.descriptor(); |
1521 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, | 1474 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, |
1522 descriptor.GetRegisterParameter(0)); | 1475 descriptor.GetRegisterParameter(0)); |
1523 __ Move(descriptor.GetRegisterParameter(1), | 1476 __ Move(descriptor.GetRegisterParameter(1), |
1524 Smi::FromInt(expr->literal_index())); | 1477 Smi::FromInt(expr->literal_index())); |
1525 __ Move(descriptor.GetRegisterParameter(2), expr->pattern()); | 1478 __ Move(descriptor.GetRegisterParameter(2), expr->pattern()); |
1526 __ Move(descriptor.GetRegisterParameter(3), Smi::FromInt(expr->flags())); | 1479 __ Move(descriptor.GetRegisterParameter(3), Smi::FromInt(expr->flags())); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 return var->scope()->is_nonlinear() || | 1913 return var->scope()->is_nonlinear() || |
1961 var->initializer_position() >= proxy->position(); | 1914 var->initializer_position() >= proxy->position(); |
1962 } | 1915 } |
1963 | 1916 |
1964 | 1917 |
1965 #undef __ | 1918 #undef __ |
1966 | 1919 |
1967 | 1920 |
1968 } // namespace internal | 1921 } // namespace internal |
1969 } // namespace v8 | 1922 } // namespace v8 |
OLD | NEW |