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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 2655853010: [TypeFeedbackVector] Combine the literals array and the feedback vector. (Closed)
Patch Set: more comments. Created 3 years, 10 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/contexts.cc ('k') | src/crankshaft/hydrogen-instructions.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 5336 matching lines...) Expand 10 before | Expand all | Expand 10 after
5347 HConstant* instr = New<HConstant>(expr->value()); 5347 HConstant* instr = New<HConstant>(expr->value());
5348 return ast_context()->ReturnInstruction(instr, expr->id()); 5348 return ast_context()->ReturnInstruction(instr, expr->id());
5349 } 5349 }
5350 5350
5351 5351
5352 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { 5352 void HOptimizedGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
5353 DCHECK(!HasStackOverflow()); 5353 DCHECK(!HasStackOverflow());
5354 DCHECK(current_block() != NULL); 5354 DCHECK(current_block() != NULL);
5355 DCHECK(current_block()->HasPredecessor()); 5355 DCHECK(current_block()->HasPredecessor());
5356 Callable callable = CodeFactory::FastCloneRegExp(isolate()); 5356 Callable callable = CodeFactory::FastCloneRegExp(isolate());
5357 HValue* values[] = {AddThisFunction(), Add<HConstant>(expr->literal_index()), 5357 int index = TypeFeedbackVector::GetIndex(expr->literal_slot());
5358 HValue* values[] = {AddThisFunction(), Add<HConstant>(index),
5358 Add<HConstant>(expr->pattern()), 5359 Add<HConstant>(expr->pattern()),
5359 Add<HConstant>(expr->flags())}; 5360 Add<HConstant>(expr->flags())};
5360 HConstant* stub_value = Add<HConstant>(callable.code()); 5361 HConstant* stub_value = Add<HConstant>(callable.code());
5361 HInstruction* instr = New<HCallWithDescriptor>( 5362 HInstruction* instr = New<HCallWithDescriptor>(
5362 stub_value, 0, callable.descriptor(), ArrayVector(values)); 5363 stub_value, 0, callable.descriptor(), ArrayVector(values));
5363 return ast_context()->ReturnInstruction(instr, expr->id()); 5364 return ast_context()->ReturnInstruction(instr, expr->id());
5364 } 5365 }
5365 5366
5366 5367
5367 static bool CanInlinePropertyAccess(Handle<Map> map) { 5368 static bool CanInlinePropertyAccess(Handle<Map> map) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5448 DCHECK(!HasStackOverflow()); 5449 DCHECK(!HasStackOverflow());
5449 DCHECK(current_block() != NULL); 5450 DCHECK(current_block() != NULL);
5450 DCHECK(current_block()->HasPredecessor()); 5451 DCHECK(current_block()->HasPredecessor());
5451 5452
5452 Handle<JSFunction> closure = function_state()->compilation_info()->closure(); 5453 Handle<JSFunction> closure = function_state()->compilation_info()->closure();
5453 HInstruction* literal; 5454 HInstruction* literal;
5454 5455
5455 // Check whether to use fast or slow deep-copying for boilerplate. 5456 // Check whether to use fast or slow deep-copying for boilerplate.
5456 int max_properties = kMaxFastLiteralProperties; 5457 int max_properties = kMaxFastLiteralProperties;
5457 Handle<Object> literals_cell( 5458 Handle<Object> literals_cell(
5458 closure->literals()->literal(expr->literal_index()), isolate()); 5459 closure->feedback_vector()->Get(expr->literal_slot()), isolate());
5459 Handle<AllocationSite> site; 5460 Handle<AllocationSite> site;
5460 Handle<JSObject> boilerplate; 5461 Handle<JSObject> boilerplate;
5461 if (!literals_cell->IsUndefined(isolate())) { 5462 if (!literals_cell->IsUndefined(isolate())) {
5462 // Retrieve the boilerplate 5463 // Retrieve the boilerplate
5463 site = Handle<AllocationSite>::cast(literals_cell); 5464 site = Handle<AllocationSite>::cast(literals_cell);
5464 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), 5465 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()),
5465 isolate()); 5466 isolate());
5466 } 5467 }
5467 5468
5468 if (!boilerplate.is_null() && 5469 if (!boilerplate.is_null() &&
5469 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { 5470 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) {
5470 AllocationSiteUsageContext site_context(isolate(), site, false); 5471 AllocationSiteUsageContext site_context(isolate(), site, false);
5471 site_context.EnterNewScope(); 5472 site_context.EnterNewScope();
5472 literal = BuildFastLiteral(boilerplate, &site_context); 5473 literal = BuildFastLiteral(boilerplate, &site_context);
5473 site_context.ExitScope(site, boilerplate); 5474 site_context.ExitScope(site, boilerplate);
5474 } else { 5475 } else {
5475 NoObservableSideEffectsScope no_effects(this); 5476 NoObservableSideEffectsScope no_effects(this);
5476 Handle<BoilerplateDescription> constant_properties = 5477 Handle<BoilerplateDescription> constant_properties =
5477 expr->GetOrBuildConstantProperties(isolate()); 5478 expr->GetOrBuildConstantProperties(isolate());
5478 int literal_index = expr->literal_index(); 5479 int literal_index = TypeFeedbackVector::GetIndex(expr->literal_slot());
5479 int flags = expr->ComputeFlags(true); 5480 int flags = expr->ComputeFlags(true);
5480 5481
5481 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), 5482 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index),
5482 Add<HConstant>(constant_properties), 5483 Add<HConstant>(constant_properties),
5483 Add<HConstant>(flags)); 5484 Add<HConstant>(flags));
5484 5485
5485 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; 5486 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral;
5486 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); 5487 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
5487 } 5488 }
5488 5489
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
5567 5568
5568 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { 5569 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
5569 DCHECK(!HasStackOverflow()); 5570 DCHECK(!HasStackOverflow());
5570 DCHECK(current_block() != NULL); 5571 DCHECK(current_block() != NULL);
5571 DCHECK(current_block()->HasPredecessor()); 5572 DCHECK(current_block()->HasPredecessor());
5572 ZoneList<Expression*>* subexprs = expr->values(); 5573 ZoneList<Expression*>* subexprs = expr->values();
5573 int length = subexprs->length(); 5574 int length = subexprs->length();
5574 HInstruction* literal; 5575 HInstruction* literal;
5575 5576
5576 Handle<AllocationSite> site; 5577 Handle<AllocationSite> site;
5577 Handle<LiteralsArray> literals(environment()->closure()->literals(), 5578 Handle<TypeFeedbackVector> vector(environment()->closure()->feedback_vector(),
5578 isolate()); 5579 isolate());
5579 Handle<Object> literals_cell(literals->literal(expr->literal_index()), 5580 Handle<Object> literals_cell(vector->Get(expr->literal_slot()), isolate());
5580 isolate());
5581 Handle<JSObject> boilerplate_object; 5581 Handle<JSObject> boilerplate_object;
5582 if (!literals_cell->IsUndefined(isolate())) { 5582 if (!literals_cell->IsUndefined(isolate())) {
5583 DCHECK(literals_cell->IsAllocationSite()); 5583 DCHECK(literals_cell->IsAllocationSite());
5584 site = Handle<AllocationSite>::cast(literals_cell); 5584 site = Handle<AllocationSite>::cast(literals_cell);
5585 boilerplate_object = Handle<JSObject>( 5585 boilerplate_object = Handle<JSObject>(
5586 JSObject::cast(site->transition_info()), isolate()); 5586 JSObject::cast(site->transition_info()), isolate());
5587 } 5587 }
5588 5588
5589 // Check whether to use fast or slow deep-copying for boilerplate. 5589 // Check whether to use fast or slow deep-copying for boilerplate.
5590 int max_properties = kMaxFastLiteralProperties; 5590 int max_properties = kMaxFastLiteralProperties;
5591 if (!boilerplate_object.is_null() && 5591 if (!boilerplate_object.is_null() &&
5592 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth, 5592 IsFastLiteral(boilerplate_object, kMaxFastLiteralDepth,
5593 &max_properties)) { 5593 &max_properties)) {
5594 DCHECK(site->SitePointsToLiteral()); 5594 DCHECK(site->SitePointsToLiteral());
5595 AllocationSiteUsageContext site_context(isolate(), site, false); 5595 AllocationSiteUsageContext site_context(isolate(), site, false);
5596 site_context.EnterNewScope(); 5596 site_context.EnterNewScope();
5597 literal = BuildFastLiteral(boilerplate_object, &site_context); 5597 literal = BuildFastLiteral(boilerplate_object, &site_context);
5598 site_context.ExitScope(site, boilerplate_object); 5598 site_context.ExitScope(site, boilerplate_object);
5599 } else { 5599 } else {
5600 NoObservableSideEffectsScope no_effects(this); 5600 NoObservableSideEffectsScope no_effects(this);
5601 Handle<ConstantElementsPair> constants = 5601 Handle<ConstantElementsPair> constants =
5602 expr->GetOrBuildConstantElements(isolate()); 5602 expr->GetOrBuildConstantElements(isolate());
5603 int literal_index = expr->literal_index(); 5603 int literal_index = TypeFeedbackVector::GetIndex(expr->literal_slot());
5604 int flags = expr->ComputeFlags(true); 5604 int flags = expr->ComputeFlags(true);
5605 5605
5606 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index), 5606 Add<HPushArguments>(AddThisFunction(), Add<HConstant>(literal_index),
5607 Add<HConstant>(constants), Add<HConstant>(flags)); 5607 Add<HConstant>(constants), Add<HConstant>(flags));
5608 5608
5609 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral; 5609 Runtime::FunctionId function_id = Runtime::kCreateArrayLiteral;
5610 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); 5610 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4);
5611 5611
5612 // Register to deopt if the boilerplate ElementsKind changes. 5612 // Register to deopt if the boilerplate ElementsKind changes.
5613 if (!site.is_null()) { 5613 if (!site.is_null()) {
(...skipping 7408 matching lines...) Expand 10 before | Expand all | Expand 10 after
13022 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13022 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13023 } 13023 }
13024 13024
13025 #ifdef DEBUG 13025 #ifdef DEBUG
13026 graph_->Verify(false); // No full verify. 13026 graph_->Verify(false); // No full verify.
13027 #endif 13027 #endif
13028 } 13028 }
13029 13029
13030 } // namespace internal 13030 } // namespace internal
13031 } // namespace v8 13031 } // namespace v8
OLDNEW
« no previous file with comments | « src/contexts.cc ('k') | src/crankshaft/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698