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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 707463002: Reland "Optimize function across closures." (again). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler.cc » ('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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bailout-reason.h" 7 #include "src/bailout-reason.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/field-index.h" 9 #include "src/field-index.h"
10 #include "src/hydrogen.h" 10 #include "src/hydrogen.h"
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 template<> 1542 template<>
1543 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() { 1543 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() {
1544 Counters* counters = isolate()->counters(); 1544 Counters* counters = isolate()->counters();
1545 Factory* factory = isolate()->factory(); 1545 Factory* factory = isolate()->factory();
1546 HInstruction* empty_fixed_array = 1546 HInstruction* empty_fixed_array =
1547 Add<HConstant>(factory->empty_fixed_array()); 1547 Add<HConstant>(factory->empty_fixed_array());
1548 HValue* shared_info = GetParameter(0); 1548 HValue* shared_info = GetParameter(0);
1549 1549
1550 AddIncrementCounter(counters->fast_new_closure_total()); 1550 AddIncrementCounter(counters->fast_new_closure_total());
1551 1551
1552 // Create a new closure from the given function info in new space 1552 IfBuilder optimize_now(this);
1553 HValue* size = Add<HConstant>(JSFunction::kSize); 1553 HInstruction* compile_hint = Add<HLoadNamedField>(
1554 HInstruction* js_function = Add<HAllocate>(size, HType::JSObject(), 1554 shared_info, static_cast<HValue*>(NULL), HObjectAccess::ForCompileHint());
1555 NOT_TENURED, JS_FUNCTION_TYPE); 1555 HValue* hint_mask = Add<HConstant>(
1556 static_cast<int32_t>(1 << SharedFunctionInfo::kOptimizeNextClosure));
1557 HInstruction* optimize =
1558 AddUncasted<HBitwise>(Token::BIT_AND, compile_hint, hint_mask);
1559 optimize_now.If<HCompareNumericAndBranch>(optimize, hint_mask, Token::EQ);
1560 optimize_now.Then();
1561 {
1562 Add<HPushArguments>(context(), shared_info, graph()->GetConstantFalse());
1563 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(),
1564 Runtime::FunctionForId(Runtime::kNewClosure), 3));
1565 }
1566 optimize_now.Else();
1567 {
1568 // Create a new closure from the given function info in new space
1569 HValue* size = Add<HConstant>(JSFunction::kSize);
1570 HInstruction* js_function =
1571 Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE);
1556 1572
1557 int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(), 1573 int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(),
1558 casted_stub()->kind()); 1574 casted_stub()->kind());
1559 1575
1560 // Compute the function map in the current native context and set that 1576 // Compute the function map in the current native context and set that
1561 // as the map of the allocated object. 1577 // as the map of the allocated object.
1562 HInstruction* native_context = BuildGetNativeContext(); 1578 HInstruction* native_context = BuildGetNativeContext();
1563 HInstruction* map_slot_value = Add<HLoadNamedField>( 1579 HInstruction* map_slot_value =
1564 native_context, static_cast<HValue*>(NULL), 1580 Add<HLoadNamedField>(native_context, static_cast<HValue*>(NULL),
1565 HObjectAccess::ForContextSlot(map_index)); 1581 HObjectAccess::ForContextSlot(map_index));
1566 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value); 1582 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
1567 1583
1568 // Initialize the rest of the function. 1584 // Initialize the rest of the function.
1569 Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(), 1585 Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(),
1570 empty_fixed_array); 1586 empty_fixed_array);
1571 Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(), 1587 Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(),
1572 empty_fixed_array); 1588 empty_fixed_array);
1573 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(), 1589 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
1574 empty_fixed_array); 1590 empty_fixed_array);
1575 Add<HStoreNamedField>(js_function, HObjectAccess::ForPrototypeOrInitialMap(), 1591 Add<HStoreNamedField>(js_function,
1576 graph()->GetConstantHole()); 1592 HObjectAccess::ForPrototypeOrInitialMap(),
1577 Add<HStoreNamedField>(js_function, 1593 graph()->GetConstantHole());
1578 HObjectAccess::ForSharedFunctionInfoPointer(), 1594 Add<HStoreNamedField>(js_function,
1579 shared_info); 1595 HObjectAccess::ForSharedFunctionInfoPointer(),
1580 Add<HStoreNamedField>(js_function, HObjectAccess::ForFunctionContextPointer(), 1596 shared_info);
1581 context()); 1597 Add<HStoreNamedField>(
1598 js_function, HObjectAccess::ForFunctionContextPointer(), context());
1582 1599
1583 // Initialize the code pointer in the function to be the one 1600 // Initialize the code pointer in the function to be the one
1584 // found in the shared function info object. 1601 // found in the shared function info object.
1585 // But first check if there is an optimized version for our context. 1602 // But first check if there is an optimized version for our context.
1586 if (FLAG_cache_optimized_code) { 1603 if (FLAG_cache_optimized_code) {
1587 BuildInstallFromOptimizedCodeMap(js_function, shared_info, native_context); 1604 BuildInstallFromOptimizedCodeMap(js_function, shared_info,
1588 } else { 1605 native_context);
1589 BuildInstallCode(js_function, shared_info); 1606 } else {
1607 BuildInstallCode(js_function, shared_info);
1608 }
1609 Push(js_function);
1590 } 1610 }
1591 1611 optimize_now.End();
1592 return js_function; 1612 return Pop();
1593 } 1613 }
1594 1614
1595 1615
1596 Handle<Code> FastNewClosureStub::GenerateCode() { 1616 Handle<Code> FastNewClosureStub::GenerateCode() {
1597 return DoGenerateCode(this); 1617 return DoGenerateCode(this);
1598 } 1618 }
1599 1619
1600 1620
1601 template<> 1621 template<>
1602 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() { 1622 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 2055
2036 // Probe the stub cache. 2056 // Probe the stub cache.
2037 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 2057 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
2038 Code::ComputeHandlerFlags(Code::LOAD_IC)); 2058 Code::ComputeHandlerFlags(Code::LOAD_IC));
2039 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); 2059 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags);
2040 2060
2041 // We never continue. 2061 // We never continue.
2042 return graph()->GetConstant0(); 2062 return graph()->GetConstant0();
2043 } 2063 }
2044 } } // namespace v8::internal 2064 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698