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

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

Issue 755173002: Partially revert "Optimize function across closures." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | « 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 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 template<> 1548 template<>
1549 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() { 1549 HValue* CodeStubGraphBuilder<FastNewClosureStub>::BuildCodeStub() {
1550 Counters* counters = isolate()->counters(); 1550 Counters* counters = isolate()->counters();
1551 Factory* factory = isolate()->factory(); 1551 Factory* factory = isolate()->factory();
1552 HInstruction* empty_fixed_array = 1552 HInstruction* empty_fixed_array =
1553 Add<HConstant>(factory->empty_fixed_array()); 1553 Add<HConstant>(factory->empty_fixed_array());
1554 HValue* shared_info = GetParameter(0); 1554 HValue* shared_info = GetParameter(0);
1555 1555
1556 AddIncrementCounter(counters->fast_new_closure_total()); 1556 AddIncrementCounter(counters->fast_new_closure_total());
1557 1557
1558 IfBuilder optimize_now(this); 1558 // Create a new closure from the given function info in new space
1559 HInstruction* compile_hint = Add<HLoadNamedField>( 1559 HValue* size = Add<HConstant>(JSFunction::kSize);
1560 shared_info, static_cast<HValue*>(NULL), HObjectAccess::ForCompileHint()); 1560 HInstruction* js_function =
1561 HValue* hint_mask = Add<HConstant>( 1561 Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE);
1562 static_cast<int32_t>(1 << SharedFunctionInfo::kOptimizeNextClosure)); 1562
1563 HInstruction* optimize = 1563 int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(),
1564 AddUncasted<HBitwise>(Token::BIT_AND, compile_hint, hint_mask); 1564 casted_stub()->kind());
1565 optimize_now.If<HCompareNumericAndBranch>(optimize, hint_mask, Token::EQ); 1565
1566 optimize_now.Then(); 1566 // Compute the function map in the current native context and set that
1567 { 1567 // as the map of the allocated object.
1568 Add<HPushArguments>(context(), shared_info, graph()->GetConstantFalse()); 1568 HInstruction* native_context = BuildGetNativeContext();
1569 Push(Add<HCallRuntime>(isolate()->factory()->empty_string(), 1569 HInstruction* map_slot_value =
1570 Runtime::FunctionForId(Runtime::kNewClosure), 3)); 1570 Add<HLoadNamedField>(native_context, static_cast<HValue*>(NULL),
1571 HObjectAccess::ForContextSlot(map_index));
1572 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
1573
1574 // Initialize the rest of the function.
1575 Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(),
1576 empty_fixed_array);
1577 Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(),
1578 empty_fixed_array);
1579 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
1580 empty_fixed_array);
1581 Add<HStoreNamedField>(js_function, HObjectAccess::ForPrototypeOrInitialMap(),
1582 graph()->GetConstantHole());
1583 Add<HStoreNamedField>(
1584 js_function, HObjectAccess::ForSharedFunctionInfoPointer(), shared_info);
1585 Add<HStoreNamedField>(js_function, HObjectAccess::ForFunctionContextPointer(),
1586 context());
1587
1588 // Initialize the code pointer in the function to be the one
1589 // found in the shared function info object.
1590 // But first check if there is an optimized version for our context.
1591 if (FLAG_cache_optimized_code) {
1592 BuildInstallFromOptimizedCodeMap(js_function, shared_info, native_context);
1593 } else {
1594 BuildInstallCode(js_function, shared_info);
1571 } 1595 }
1572 optimize_now.Else();
1573 {
1574 // Create a new closure from the given function info in new space
1575 HValue* size = Add<HConstant>(JSFunction::kSize);
1576 HInstruction* js_function =
1577 Add<HAllocate>(size, HType::JSObject(), NOT_TENURED, JS_FUNCTION_TYPE);
1578 1596
1579 int map_index = Context::FunctionMapIndex(casted_stub()->strict_mode(), 1597 return js_function;
1580 casted_stub()->kind());
1581
1582 // Compute the function map in the current native context and set that
1583 // as the map of the allocated object.
1584 HInstruction* native_context = BuildGetNativeContext();
1585 HInstruction* map_slot_value =
1586 Add<HLoadNamedField>(native_context, static_cast<HValue*>(NULL),
1587 HObjectAccess::ForContextSlot(map_index));
1588 Add<HStoreNamedField>(js_function, HObjectAccess::ForMap(), map_slot_value);
1589
1590 // Initialize the rest of the function.
1591 Add<HStoreNamedField>(js_function, HObjectAccess::ForPropertiesPointer(),
1592 empty_fixed_array);
1593 Add<HStoreNamedField>(js_function, HObjectAccess::ForElementsPointer(),
1594 empty_fixed_array);
1595 Add<HStoreNamedField>(js_function, HObjectAccess::ForLiteralsPointer(),
1596 empty_fixed_array);
1597 Add<HStoreNamedField>(js_function,
1598 HObjectAccess::ForPrototypeOrInitialMap(),
1599 graph()->GetConstantHole());
1600 Add<HStoreNamedField>(js_function,
1601 HObjectAccess::ForSharedFunctionInfoPointer(),
1602 shared_info);
1603 Add<HStoreNamedField>(
1604 js_function, HObjectAccess::ForFunctionContextPointer(), context());
1605
1606 // Initialize the code pointer in the function to be the one
1607 // found in the shared function info object.
1608 // But first check if there is an optimized version for our context.
1609 if (FLAG_cache_optimized_code) {
1610 BuildInstallFromOptimizedCodeMap(js_function, shared_info,
1611 native_context);
1612 } else {
1613 BuildInstallCode(js_function, shared_info);
1614 }
1615 Push(js_function);
1616 }
1617 optimize_now.End();
1618 return Pop();
1619 } 1598 }
1620 1599
1621 1600
1622 Handle<Code> FastNewClosureStub::GenerateCode() { 1601 Handle<Code> FastNewClosureStub::GenerateCode() {
1623 return DoGenerateCode(this); 1602 return DoGenerateCode(this);
1624 } 1603 }
1625 1604
1626 1605
1627 template<> 1606 template<>
1628 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() { 1607 HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 2040
2062 // Probe the stub cache. 2041 // Probe the stub cache.
2063 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags( 2042 Code::Flags flags = Code::RemoveTypeAndHolderFromFlags(
2064 Code::ComputeHandlerFlags(Code::LOAD_IC)); 2043 Code::ComputeHandlerFlags(Code::LOAD_IC));
2065 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags); 2044 Add<HTailCallThroughMegamorphicCache>(receiver, name, flags);
2066 2045
2067 // We never continue. 2046 // We never continue.
2068 return graph()->GetConstant0(); 2047 return graph()->GetConstant0();
2069 } 2048 }
2070 } } // namespace v8::internal 2049 } } // 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