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

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

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