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