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 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 SetStackOverflow(); | 1439 SetStackOverflow(); |
1440 return; | 1440 return; |
1441 } | 1441 } |
1442 EmitNewClosure(function_info, expr->pretenure()); | 1442 EmitNewClosure(function_info, expr->pretenure()); |
1443 } | 1443 } |
1444 | 1444 |
1445 | 1445 |
1446 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { | 1446 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { |
1447 Comment cmnt(masm_, "[ ClassLiteral"); | 1447 Comment cmnt(masm_, "[ ClassLiteral"); |
1448 | 1448 |
1449 if (lit->extends() != NULL) { | 1449 { |
1450 VisitForStackValue(lit->extends()); | 1450 NestedClassLiteral nested_class_literal(this, lit); |
1451 } else { | 1451 EnterBlockScopeIfNeeded block_scope_state( |
1452 PushOperand(isolate()->factory()->the_hole_value()); | 1452 this, lit->scope(), lit->EntryId(), lit->DeclsId(), lit->ExitId()); |
1453 } | |
1454 | 1453 |
1455 VisitForStackValue(lit->constructor()); | 1454 if (lit->extends() != NULL) { |
| 1455 VisitForStackValue(lit->extends()); |
| 1456 } else { |
| 1457 PushOperand(isolate()->factory()->the_hole_value()); |
| 1458 } |
1456 | 1459 |
1457 PushOperand(Smi::FromInt(lit->start_position())); | 1460 VisitForStackValue(lit->constructor()); |
1458 PushOperand(Smi::FromInt(lit->end_position())); | |
1459 | 1461 |
1460 CallRuntimeWithOperands(Runtime::kDefineClass); | 1462 PushOperand(Smi::FromInt(lit->start_position())); |
1461 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER); | 1463 PushOperand(Smi::FromInt(lit->end_position())); |
1462 PushOperand(result_register()); | |
1463 | 1464 |
1464 // Load the "prototype" from the constructor. | 1465 CallRuntimeWithOperands(Runtime::kDefineClass); |
1465 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); | 1466 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER); |
1466 __ LoadRoot(LoadDescriptor::NameRegister(), Heap::kprototype_stringRootIndex); | 1467 PushOperand(result_register()); |
1467 __ Move(LoadDescriptor::SlotRegister(), SmiFromSlot(lit->PrototypeSlot())); | |
1468 CallLoadIC(); | |
1469 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER); | |
1470 PushOperand(result_register()); | |
1471 | 1468 |
1472 EmitClassDefineProperties(lit); | 1469 // Load the "prototype" from the constructor. |
1473 DropOperands(1); | 1470 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); |
| 1471 __ LoadRoot(LoadDescriptor::NameRegister(), |
| 1472 Heap::kprototype_stringRootIndex); |
| 1473 __ Move(LoadDescriptor::SlotRegister(), SmiFromSlot(lit->PrototypeSlot())); |
| 1474 CallLoadIC(); |
| 1475 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER); |
| 1476 PushOperand(result_register()); |
1474 | 1477 |
1475 // Set the constructor to have fast properties. | 1478 EmitClassDefineProperties(lit); |
1476 CallRuntimeWithOperands(Runtime::kToFastProperties); | 1479 DropOperands(1); |
1477 | 1480 |
1478 if (lit->class_variable_proxy() != nullptr) { | 1481 // Set the constructor to have fast properties. |
1479 EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT, | 1482 CallRuntimeWithOperands(Runtime::kToFastProperties); |
1480 lit->ProxySlot()); | 1483 |
| 1484 if (lit->class_variable_proxy() != nullptr) { |
| 1485 EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT, |
| 1486 lit->ProxySlot()); |
| 1487 } |
1481 } | 1488 } |
1482 | 1489 |
1483 context()->Plug(result_register()); | 1490 context()->Plug(result_register()); |
1484 } | 1491 } |
1485 | 1492 |
1486 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1493 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
1487 Comment cmnt(masm_, "[ RegExpLiteral"); | 1494 Comment cmnt(masm_, "[ RegExpLiteral"); |
1488 Callable callable = CodeFactory::FastCloneRegExp(isolate()); | 1495 Callable callable = CodeFactory::FastCloneRegExp(isolate()); |
1489 CallInterfaceDescriptor descriptor = callable.descriptor(); | 1496 CallInterfaceDescriptor descriptor = callable.descriptor(); |
1490 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, | 1497 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1930 return var->scope()->is_nonlinear() || | 1937 return var->scope()->is_nonlinear() || |
1931 var->initializer_position() >= proxy->position(); | 1938 var->initializer_position() >= proxy->position(); |
1932 } | 1939 } |
1933 | 1940 |
1934 | 1941 |
1935 #undef __ | 1942 #undef __ |
1936 | 1943 |
1937 | 1944 |
1938 } // namespace internal | 1945 } // namespace internal |
1939 } // namespace v8 | 1946 } // namespace v8 |
OLD | NEW |