Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/full-codegen/full-codegen.cc

Issue 2176653003: Wrap ClassLiterals in DoExpressions instead of giving them BlockScopes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/full-codegen.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 { 1449 if (lit->extends() != NULL) {
1450 NestedClassLiteral nested_class_literal(this, lit); 1450 VisitForStackValue(lit->extends());
1451 EnterBlockScopeIfNeeded block_scope_state( 1451 } else {
1452 this, lit->scope(), lit->EntryId(), lit->DeclsId(), lit->ExitId()); 1452 PushOperand(isolate()->factory()->the_hole_value());
1453 }
1453 1454
1454 if (lit->extends() != NULL) { 1455 VisitForStackValue(lit->constructor());
1455 VisitForStackValue(lit->extends());
1456 } else {
1457 PushOperand(isolate()->factory()->the_hole_value());
1458 }
1459 1456
1460 VisitForStackValue(lit->constructor()); 1457 PushOperand(Smi::FromInt(lit->start_position()));
1458 PushOperand(Smi::FromInt(lit->end_position()));
1461 1459
1462 PushOperand(Smi::FromInt(lit->start_position())); 1460 CallRuntimeWithOperands(Runtime::kDefineClass);
1463 PushOperand(Smi::FromInt(lit->end_position())); 1461 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER);
1462 PushOperand(result_register());
1464 1463
1465 CallRuntimeWithOperands(Runtime::kDefineClass); 1464 // Load the "prototype" from the constructor.
1466 PrepareForBailoutForId(lit->CreateLiteralId(), BailoutState::TOS_REGISTER); 1465 __ Move(LoadDescriptor::ReceiverRegister(), result_register());
1467 PushOperand(result_register()); 1466 __ LoadRoot(LoadDescriptor::NameRegister(), Heap::kprototype_stringRootIndex);
1467 __ Move(LoadDescriptor::SlotRegister(), SmiFromSlot(lit->PrototypeSlot()));
1468 CallLoadIC();
1469 PrepareForBailoutForId(lit->PrototypeId(), BailoutState::TOS_REGISTER);
1470 PushOperand(result_register());
1468 1471
1469 // Load the "prototype" from the constructor. 1472 EmitClassDefineProperties(lit);
1470 __ Move(LoadDescriptor::ReceiverRegister(), result_register()); 1473 DropOperands(1);
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());
1477 1474
1478 EmitClassDefineProperties(lit); 1475 // Set the constructor to have fast properties.
1479 DropOperands(1); 1476 CallRuntimeWithOperands(Runtime::kToFastProperties);
1480 1477
1481 // Set the constructor to have fast properties. 1478 if (lit->class_variable_proxy() != nullptr) {
1482 CallRuntimeWithOperands(Runtime::kToFastProperties); 1479 EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT,
1483 1480 lit->ProxySlot());
1484 if (lit->class_variable_proxy() != nullptr) {
1485 EmitVariableAssignment(lit->class_variable_proxy()->var(), Token::INIT,
1486 lit->ProxySlot());
1487 }
1488 } 1481 }
1489 1482
1490 context()->Plug(result_register()); 1483 context()->Plug(result_register());
1491 } 1484 }
1492 1485
1493 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { 1486 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1494 Comment cmnt(masm_, "[ RegExpLiteral"); 1487 Comment cmnt(masm_, "[ RegExpLiteral");
1495 Callable callable = CodeFactory::FastCloneRegExp(isolate()); 1488 Callable callable = CodeFactory::FastCloneRegExp(isolate());
1496 CallInterfaceDescriptor descriptor = callable.descriptor(); 1489 CallInterfaceDescriptor descriptor = callable.descriptor();
1497 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset, 1490 LoadFromFrameField(JavaScriptFrameConstants::kFunctionOffset,
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 return var->scope()->is_nonlinear() || 1930 return var->scope()->is_nonlinear() ||
1938 var->initializer_position() >= proxy->position(); 1931 var->initializer_position() >= proxy->position();
1939 } 1932 }
1940 1933
1941 1934
1942 #undef __ 1935 #undef __
1943 1936
1944 1937
1945 } // namespace internal 1938 } // namespace internal
1946 } // namespace v8 1939 } // namespace v8
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.h ('k') | src/interpreter/bytecode-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698