OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/js-type-feedback.h" | |
10 #include "src/compiler/linkage.h" | 11 #include "src/compiler/linkage.h" |
11 #include "src/compiler/liveness-analyzer.h" | 12 #include "src/compiler/liveness-analyzer.h" |
12 #include "src/compiler/machine-operator.h" | 13 #include "src/compiler/machine-operator.h" |
13 #include "src/compiler/node-matchers.h" | 14 #include "src/compiler/node-matchers.h" |
14 #include "src/compiler/node-properties.h" | 15 #include "src/compiler/node-properties.h" |
15 #include "src/compiler/operator-properties.h" | 16 #include "src/compiler/operator-properties.h" |
16 #include "src/compiler/state-values-utils.h" | 17 #include "src/compiler/state-values-utils.h" |
17 #include "src/full-codegen.h" | 18 #include "src/full-codegen.h" |
18 #include "src/parser.h" | 19 #include "src/parser.h" |
19 #include "src/scopes.h" | 20 #include "src/scopes.h" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 return true; | 375 return true; |
375 } | 376 } |
376 | 377 |
377 private: | 378 private: |
378 DeferredCommands* commands_; | 379 DeferredCommands* commands_; |
379 TryFinallyBuilder* control_; | 380 TryFinallyBuilder* control_; |
380 }; | 381 }; |
381 | 382 |
382 | 383 |
383 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, | 384 AstGraphBuilder::AstGraphBuilder(Zone* local_zone, CompilationInfo* info, |
384 JSGraph* jsgraph, LoopAssignmentAnalysis* loop) | 385 JSGraph* jsgraph, LoopAssignmentAnalysis* loop, |
386 JSTypeFeedbackTable* js_type_feedback) | |
385 : local_zone_(local_zone), | 387 : local_zone_(local_zone), |
386 info_(info), | 388 info_(info), |
387 jsgraph_(jsgraph), | 389 jsgraph_(jsgraph), |
388 environment_(nullptr), | 390 environment_(nullptr), |
389 ast_context_(nullptr), | 391 ast_context_(nullptr), |
390 globals_(0, local_zone), | 392 globals_(0, local_zone), |
391 execution_control_(nullptr), | 393 execution_control_(nullptr), |
392 execution_context_(nullptr), | 394 execution_context_(nullptr), |
393 try_nesting_level_(0), | 395 try_nesting_level_(0), |
394 input_buffer_size_(0), | 396 input_buffer_size_(0), |
395 input_buffer_(nullptr), | 397 input_buffer_(nullptr), |
396 exit_control_(nullptr), | 398 exit_control_(nullptr), |
397 loop_assignment_analysis_(loop), | 399 loop_assignment_analysis_(loop), |
398 state_values_cache_(jsgraph), | 400 state_values_cache_(jsgraph), |
399 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), | 401 liveness_analyzer_(static_cast<size_t>(info->scope()->num_stack_slots()), |
400 local_zone) { | 402 local_zone), |
403 js_type_feedback_(js_type_feedback) { | |
401 InitializeAstVisitor(info->isolate(), local_zone); | 404 InitializeAstVisitor(info->isolate(), local_zone); |
402 } | 405 } |
403 | 406 |
404 | 407 |
405 Node* AstGraphBuilder::GetFunctionClosure() { | 408 Node* AstGraphBuilder::GetFunctionClosure() { |
406 if (!function_closure_.is_set()) { | 409 if (!function_closure_.is_set()) { |
407 const Operator* op = | 410 const Operator* op = |
408 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); | 411 common()->Parameter(Linkage::kJSFunctionCallClosureParamIndex); |
409 Node* node = NewNode(op, graph()->start()); | 412 Node* node = NewNode(op, graph()->start()); |
410 function_closure_.set(node); | 413 function_closure_.set(node); |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1651 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1654 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1652 // Fall through. | 1655 // Fall through. |
1653 case ObjectLiteral::Property::COMPUTED: { | 1656 case ObjectLiteral::Property::COMPUTED: { |
1654 // It is safe to use [[Put]] here because the boilerplate already | 1657 // It is safe to use [[Put]] here because the boilerplate already |
1655 // contains computed properties with an uninitialized value. | 1658 // contains computed properties with an uninitialized value. |
1656 if (key->value()->IsInternalizedString()) { | 1659 if (key->value()->IsInternalizedString()) { |
1657 if (property->emit_store()) { | 1660 if (property->emit_store()) { |
1658 VisitForValue(property->value()); | 1661 VisitForValue(property->value()); |
1659 Node* value = environment()->Pop(); | 1662 Node* value = environment()->Pop(); |
1660 Handle<Name> name = key->AsPropertyName(); | 1663 Handle<Name> name = key->AsPropertyName(); |
1661 Node* store = BuildNamedStore(literal, name, value); | 1664 Node* store = |
1665 BuildNamedStore(literal, name, value, TypeFeedbackId::None()); | |
1662 PrepareFrameState(store, key->id()); | 1666 PrepareFrameState(store, key->id()); |
1663 BuildSetHomeObject(value, literal, property->value()); | 1667 BuildSetHomeObject(value, literal, property->value()); |
1664 } else { | 1668 } else { |
1665 VisitForEffect(property->value()); | 1669 VisitForEffect(property->value()); |
1666 } | 1670 } |
1667 break; | 1671 break; |
1668 } | 1672 } |
1669 environment()->Push(literal); // Duplicate receiver. | 1673 environment()->Push(literal); // Duplicate receiver. |
1670 VisitForValue(property->key()); | 1674 VisitForValue(property->key()); |
1671 VisitForValue(property->value()); | 1675 VisitForValue(property->value()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1826 // them into the newly cloned array. | 1830 // them into the newly cloned array. |
1827 for (int i = 0; i < expr->values()->length(); i++) { | 1831 for (int i = 0; i < expr->values()->length(); i++) { |
1828 Expression* subexpr = expr->values()->at(i); | 1832 Expression* subexpr = expr->values()->at(i); |
1829 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 1833 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
1830 | 1834 |
1831 VisitForValue(subexpr); | 1835 VisitForValue(subexpr); |
1832 Node* frame_state_before = environment()->Checkpoint( | 1836 Node* frame_state_before = environment()->Checkpoint( |
1833 subexpr->id(), OutputFrameStateCombine::PokeAt(0)); | 1837 subexpr->id(), OutputFrameStateCombine::PokeAt(0)); |
1834 Node* value = environment()->Pop(); | 1838 Node* value = environment()->Pop(); |
1835 Node* index = jsgraph()->Constant(i); | 1839 Node* index = jsgraph()->Constant(i); |
1836 Node* store = BuildKeyedStore(literal, index, value); | 1840 Node* store = |
1841 BuildKeyedStore(literal, index, value, TypeFeedbackId::None()); | |
1837 PrepareFrameStateAfterAndBefore(store, expr->GetIdForElement(i), | 1842 PrepareFrameStateAfterAndBefore(store, expr->GetIdForElement(i), |
1838 OutputFrameStateCombine::Ignore(), | 1843 OutputFrameStateCombine::Ignore(), |
1839 frame_state_before); | 1844 frame_state_before); |
1840 } | 1845 } |
1841 | 1846 |
1842 environment()->Pop(); // Array literal index. | 1847 environment()->Pop(); // Array literal index. |
1843 ast_context()->ProduceValue(environment()->Pop()); | 1848 ast_context()->ProduceValue(environment()->Pop()); |
1844 } | 1849 } |
1845 | 1850 |
1846 | 1851 |
(...skipping 11 matching lines...) Expand all Loading... | |
1858 Variable* var = expr->AsVariableProxy()->var(); | 1863 Variable* var = expr->AsVariableProxy()->var(); |
1859 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); | 1864 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); |
1860 break; | 1865 break; |
1861 } | 1866 } |
1862 case NAMED_PROPERTY: { | 1867 case NAMED_PROPERTY: { |
1863 environment()->Push(value); | 1868 environment()->Push(value); |
1864 VisitForValue(property->obj()); | 1869 VisitForValue(property->obj()); |
1865 Node* object = environment()->Pop(); | 1870 Node* object = environment()->Pop(); |
1866 value = environment()->Pop(); | 1871 value = environment()->Pop(); |
1867 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 1872 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
1868 Node* store = BuildNamedStore(object, name, value); | 1873 Node* store = |
1874 BuildNamedStore(object, name, value, TypeFeedbackId::None()); | |
1869 PrepareFrameState(store, bailout_id); | 1875 PrepareFrameState(store, bailout_id); |
1870 break; | 1876 break; |
1871 } | 1877 } |
1872 case KEYED_PROPERTY: { | 1878 case KEYED_PROPERTY: { |
1873 environment()->Push(value); | 1879 environment()->Push(value); |
1874 VisitForValue(property->obj()); | 1880 VisitForValue(property->obj()); |
1875 VisitForValue(property->key()); | 1881 VisitForValue(property->key()); |
1876 Node* key = environment()->Pop(); | 1882 Node* key = environment()->Pop(); |
1877 Node* object = environment()->Pop(); | 1883 Node* object = environment()->Pop(); |
1878 value = environment()->Pop(); | 1884 value = environment()->Pop(); |
1879 Node* store = BuildKeyedStore(object, key, value); | 1885 Node* store = BuildKeyedStore(object, key, value, TypeFeedbackId::None()); |
1880 // TODO(jarin) Provide a real frame state before. | 1886 // TODO(jarin) Provide a real frame state before. |
1881 PrepareFrameStateAfterAndBefore(store, bailout_id, | 1887 PrepareFrameStateAfterAndBefore(store, bailout_id, |
1882 OutputFrameStateCombine::Ignore(), | 1888 OutputFrameStateCombine::Ignore(), |
1883 jsgraph()->EmptyFrameState()); | 1889 jsgraph()->EmptyFrameState()); |
1884 break; | 1890 break; |
1885 } | 1891 } |
1886 } | 1892 } |
1887 } | 1893 } |
1888 | 1894 |
1889 | 1895 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1921 VectorSlotPair pair = | 1927 VectorSlotPair pair = |
1922 CreateVectorSlotPair(proxy->VariableFeedbackSlot()); | 1928 CreateVectorSlotPair(proxy->VariableFeedbackSlot()); |
1923 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair); | 1929 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair); |
1924 break; | 1930 break; |
1925 } | 1931 } |
1926 case NAMED_PROPERTY: { | 1932 case NAMED_PROPERTY: { |
1927 Node* object = environment()->Top(); | 1933 Node* object = environment()->Top(); |
1928 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 1934 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
1929 VectorSlotPair pair = | 1935 VectorSlotPair pair = |
1930 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 1936 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
1931 old_value = BuildNamedLoad(object, name, pair); | 1937 old_value = |
1938 BuildNamedLoad(object, name, pair, expr->AssignmentFeedbackId()); | |
Michael Starzinger
2015/03/24 09:06:40
Shouldn't the property loads in the assignment use
titzer
2015/03/24 10:49:31
I cribbed from typing.cc which adds the type feedb
Michael Starzinger
2015/03/24 12:11:18
As discussed offline: In typing.cc the AstTyper::V
titzer
2015/03/24 14:52:06
Done.
| |
1932 PrepareFrameState(old_value, property->LoadId(), | 1939 PrepareFrameState(old_value, property->LoadId(), |
1933 OutputFrameStateCombine::Push()); | 1940 OutputFrameStateCombine::Push()); |
1934 break; | 1941 break; |
1935 } | 1942 } |
1936 case KEYED_PROPERTY: { | 1943 case KEYED_PROPERTY: { |
1937 Node* key = environment()->Top(); | 1944 Node* key = environment()->Top(); |
1938 Node* object = environment()->Peek(1); | 1945 Node* object = environment()->Peek(1); |
1939 VectorSlotPair pair = | 1946 VectorSlotPair pair = |
1940 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 1947 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
1941 old_value = BuildKeyedLoad(object, key, pair); | 1948 old_value = |
1949 BuildKeyedLoad(object, key, pair, expr->AssignmentFeedbackId()); | |
Michael Starzinger
2015/03/24 09:06:40
Likewise.
titzer
2015/03/24 10:49:31
Same as above.
Michael Starzinger
2015/03/24 12:11:17
Likewise.
titzer
2015/03/24 14:52:06
Done.
| |
1942 PrepareFrameState(old_value, property->LoadId(), | 1950 PrepareFrameState(old_value, property->LoadId(), |
1943 OutputFrameStateCombine::Push()); | 1951 OutputFrameStateCombine::Push()); |
1944 break; | 1952 break; |
1945 } | 1953 } |
1946 } | 1954 } |
1947 environment()->Push(old_value); | 1955 environment()->Push(old_value); |
1948 VisitForValue(expr->value()); | 1956 VisitForValue(expr->value()); |
1949 Node* frame_state_before = environment()->Checkpoint(expr->value()->id()); | 1957 Node* frame_state_before = environment()->Checkpoint(expr->value()->id()); |
1950 Node* right = environment()->Pop(); | 1958 Node* right = environment()->Pop(); |
1951 Node* left = environment()->Pop(); | 1959 Node* left = environment()->Pop(); |
(...skipping 24 matching lines...) Expand all Loading... | |
1976 switch (assign_type) { | 1984 switch (assign_type) { |
1977 case VARIABLE: { | 1985 case VARIABLE: { |
1978 Variable* variable = expr->target()->AsVariableProxy()->var(); | 1986 Variable* variable = expr->target()->AsVariableProxy()->var(); |
1979 BuildVariableAssignment(variable, value, expr->op(), expr->id(), | 1987 BuildVariableAssignment(variable, value, expr->op(), expr->id(), |
1980 ast_context()->GetStateCombine()); | 1988 ast_context()->GetStateCombine()); |
1981 break; | 1989 break; |
1982 } | 1990 } |
1983 case NAMED_PROPERTY: { | 1991 case NAMED_PROPERTY: { |
1984 Node* object = environment()->Pop(); | 1992 Node* object = environment()->Pop(); |
1985 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 1993 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
1986 Node* store = BuildNamedStore(object, name, value); | 1994 Node* store = |
1995 BuildNamedStore(object, name, value, expr->AssignmentFeedbackId()); | |
1987 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine()); | 1996 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine()); |
1988 break; | 1997 break; |
1989 } | 1998 } |
1990 case KEYED_PROPERTY: { | 1999 case KEYED_PROPERTY: { |
1991 Node* key = environment()->Pop(); | 2000 Node* key = environment()->Pop(); |
1992 Node* object = environment()->Pop(); | 2001 Node* object = environment()->Pop(); |
1993 Node* store = BuildKeyedStore(object, key, value); | 2002 Node* store = |
2003 BuildKeyedStore(object, key, value, expr->AssignmentFeedbackId()); | |
1994 PrepareFrameStateAfterAndBefore(store, expr->id(), | 2004 PrepareFrameStateAfterAndBefore(store, expr->id(), |
1995 ast_context()->GetStateCombine(), | 2005 ast_context()->GetStateCombine(), |
1996 frame_state_before_store); | 2006 frame_state_before_store); |
1997 break; | 2007 break; |
1998 } | 2008 } |
1999 } | 2009 } |
2000 | 2010 |
2001 ast_context()->ProduceValue(value); | 2011 ast_context()->ProduceValue(value); |
2002 } | 2012 } |
2003 | 2013 |
(...skipping 13 matching lines...) Expand all Loading... | |
2017 } | 2027 } |
2018 | 2028 |
2019 | 2029 |
2020 void AstGraphBuilder::VisitProperty(Property* expr) { | 2030 void AstGraphBuilder::VisitProperty(Property* expr) { |
2021 Node* value; | 2031 Node* value; |
2022 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot()); | 2032 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot()); |
2023 if (expr->key()->IsPropertyName()) { | 2033 if (expr->key()->IsPropertyName()) { |
2024 VisitForValue(expr->obj()); | 2034 VisitForValue(expr->obj()); |
2025 Node* object = environment()->Pop(); | 2035 Node* object = environment()->Pop(); |
2026 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName(); | 2036 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName(); |
2027 value = BuildNamedLoad(object, name, pair); | 2037 value = BuildNamedLoad(object, name, pair, expr->PropertyFeedbackId()); |
2028 } else { | 2038 } else { |
2029 VisitForValue(expr->obj()); | 2039 VisitForValue(expr->obj()); |
2030 VisitForValue(expr->key()); | 2040 VisitForValue(expr->key()); |
2031 Node* key = environment()->Pop(); | 2041 Node* key = environment()->Pop(); |
2032 Node* object = environment()->Pop(); | 2042 Node* object = environment()->Pop(); |
2033 value = BuildKeyedLoad(object, key, pair); | 2043 value = BuildKeyedLoad(object, key, pair, expr->PropertyFeedbackId()); |
2034 } | 2044 } |
2035 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); | 2045 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); |
2036 ast_context()->ProduceValue(value); | 2046 ast_context()->ProduceValue(value); |
2037 } | 2047 } |
2038 | 2048 |
2039 | 2049 |
2040 void AstGraphBuilder::VisitCall(Call* expr) { | 2050 void AstGraphBuilder::VisitCall(Call* expr) { |
2041 Expression* callee = expr->expression(); | 2051 Expression* callee = expr->expression(); |
2042 Call::CallType call_type = expr->GetCallType(isolate()); | 2052 Call::CallType call_type = expr->GetCallType(isolate()); |
2043 | 2053 |
(...skipping 27 matching lines...) Expand all Loading... | |
2071 break; | 2081 break; |
2072 } | 2082 } |
2073 case Call::PROPERTY_CALL: { | 2083 case Call::PROPERTY_CALL: { |
2074 Property* property = callee->AsProperty(); | 2084 Property* property = callee->AsProperty(); |
2075 VisitForValue(property->obj()); | 2085 VisitForValue(property->obj()); |
2076 Node* object = environment()->Top(); | 2086 Node* object = environment()->Top(); |
2077 VectorSlotPair pair = | 2087 VectorSlotPair pair = |
2078 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 2088 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
2079 if (property->key()->IsPropertyName()) { | 2089 if (property->key()->IsPropertyName()) { |
2080 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 2090 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
2081 callee_value = BuildNamedLoad(object, name, pair); | 2091 callee_value = |
2092 BuildNamedLoad(object, name, pair, property->PropertyFeedbackId()); | |
2082 } else { | 2093 } else { |
2083 VisitForValue(property->key()); | 2094 VisitForValue(property->key()); |
2084 Node* key = environment()->Pop(); | 2095 Node* key = environment()->Pop(); |
2085 callee_value = BuildKeyedLoad(object, key, pair); | 2096 callee_value = |
2097 BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId()); | |
2086 } | 2098 } |
2087 PrepareFrameState(callee_value, property->LoadId(), | 2099 PrepareFrameState(callee_value, property->LoadId(), |
2088 OutputFrameStateCombine::Push()); | 2100 OutputFrameStateCombine::Push()); |
2089 receiver_value = environment()->Pop(); | 2101 receiver_value = environment()->Pop(); |
2090 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an | 2102 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an |
2091 // object for sloppy callees. This could also be modeled explicitly here, | 2103 // object for sloppy callees. This could also be modeled explicitly here, |
2092 // thereby obsoleting the need for a flag to the call operator. | 2104 // thereby obsoleting the need for a flag to the call operator. |
2093 flags = CALL_AS_METHOD; | 2105 flags = CALL_AS_METHOD; |
2094 break; | 2106 break; |
2095 } | 2107 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2171 | 2183 |
2172 | 2184 |
2173 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { | 2185 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { |
2174 Handle<String> name = expr->name(); | 2186 Handle<String> name = expr->name(); |
2175 | 2187 |
2176 // The callee and the receiver both have to be pushed onto the operand stack | 2188 // The callee and the receiver both have to be pushed onto the operand stack |
2177 // before arguments are being evaluated. | 2189 // before arguments are being evaluated. |
2178 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; | 2190 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; |
2179 Node* receiver_value = BuildLoadBuiltinsObject(); | 2191 Node* receiver_value = BuildLoadBuiltinsObject(); |
2180 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); | 2192 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); |
2181 Node* callee_value = BuildNamedLoad(receiver_value, name, pair); | 2193 Node* callee_value = |
2194 BuildNamedLoad(receiver_value, name, pair, expr->CallRuntimeFeedbackId()); | |
2182 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft | 2195 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft |
2183 // refuses to optimize functions with jsruntime calls). | 2196 // refuses to optimize functions with jsruntime calls). |
2184 PrepareFrameState(callee_value, BailoutId::None(), | 2197 PrepareFrameState(callee_value, BailoutId::None(), |
2185 OutputFrameStateCombine::Push()); | 2198 OutputFrameStateCombine::Push()); |
2186 environment()->Push(callee_value); | 2199 environment()->Push(callee_value); |
2187 environment()->Push(receiver_value); | 2200 environment()->Push(receiver_value); |
2188 | 2201 |
2189 // Evaluate all arguments to the JS runtime call. | 2202 // Evaluate all arguments to the JS runtime call. |
2190 ZoneList<Expression*>* args = expr->arguments(); | 2203 ZoneList<Expression*>* args = expr->arguments(); |
2191 VisitForValues(args); | 2204 VisitForValues(args); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2259 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair); | 2272 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair); |
2260 stack_depth = 0; | 2273 stack_depth = 0; |
2261 break; | 2274 break; |
2262 } | 2275 } |
2263 case NAMED_PROPERTY: { | 2276 case NAMED_PROPERTY: { |
2264 VisitForValue(property->obj()); | 2277 VisitForValue(property->obj()); |
2265 Node* object = environment()->Top(); | 2278 Node* object = environment()->Top(); |
2266 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 2279 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
2267 VectorSlotPair pair = | 2280 VectorSlotPair pair = |
2268 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 2281 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
2269 old_value = BuildNamedLoad(object, name, pair); | 2282 old_value = |
2283 BuildNamedLoad(object, name, pair, property->PropertyFeedbackId()); | |
2270 PrepareFrameState(old_value, property->LoadId(), | 2284 PrepareFrameState(old_value, property->LoadId(), |
2271 OutputFrameStateCombine::Push()); | 2285 OutputFrameStateCombine::Push()); |
2272 stack_depth = 1; | 2286 stack_depth = 1; |
2273 break; | 2287 break; |
2274 } | 2288 } |
2275 case KEYED_PROPERTY: { | 2289 case KEYED_PROPERTY: { |
2276 VisitForValue(property->obj()); | 2290 VisitForValue(property->obj()); |
2277 VisitForValue(property->key()); | 2291 VisitForValue(property->key()); |
2278 Node* key = environment()->Top(); | 2292 Node* key = environment()->Top(); |
2279 Node* object = environment()->Peek(1); | 2293 Node* object = environment()->Peek(1); |
2280 VectorSlotPair pair = | 2294 VectorSlotPair pair = |
2281 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 2295 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
2282 old_value = BuildKeyedLoad(object, key, pair); | 2296 old_value = |
2297 BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId()); | |
2283 PrepareFrameState(old_value, property->LoadId(), | 2298 PrepareFrameState(old_value, property->LoadId(), |
2284 OutputFrameStateCombine::Push()); | 2299 OutputFrameStateCombine::Push()); |
2285 stack_depth = 2; | 2300 stack_depth = 2; |
2286 break; | 2301 break; |
2287 } | 2302 } |
2288 } | 2303 } |
2289 | 2304 |
2290 // Convert old value into a number. | 2305 // Convert old value into a number. |
2291 old_value = NewNode(javascript()->ToNumber(), old_value); | 2306 old_value = NewNode(javascript()->ToNumber(), old_value); |
2292 PrepareFrameState(old_value, expr->ToNumberId(), | 2307 PrepareFrameState(old_value, expr->ToNumberId(), |
(...skipping 22 matching lines...) Expand all Loading... | |
2315 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 2330 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
2316 environment()->Push(value); | 2331 environment()->Push(value); |
2317 BuildVariableAssignment(variable, value, expr->op(), | 2332 BuildVariableAssignment(variable, value, expr->op(), |
2318 expr->AssignmentId()); | 2333 expr->AssignmentId()); |
2319 environment()->Pop(); | 2334 environment()->Pop(); |
2320 break; | 2335 break; |
2321 } | 2336 } |
2322 case NAMED_PROPERTY: { | 2337 case NAMED_PROPERTY: { |
2323 Node* object = environment()->Pop(); | 2338 Node* object = environment()->Pop(); |
2324 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 2339 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
2325 Node* store = BuildNamedStore(object, name, value); | 2340 Node* store = |
2341 BuildNamedStore(object, name, value, expr->CountStoreFeedbackId()); | |
2326 environment()->Push(value); | 2342 environment()->Push(value); |
2327 PrepareFrameState(store, expr->AssignmentId()); | 2343 PrepareFrameState(store, expr->AssignmentId()); |
2328 environment()->Pop(); | 2344 environment()->Pop(); |
2329 break; | 2345 break; |
2330 } | 2346 } |
2331 case KEYED_PROPERTY: { | 2347 case KEYED_PROPERTY: { |
2332 Node* key = environment()->Pop(); | 2348 Node* key = environment()->Pop(); |
2333 Node* object = environment()->Pop(); | 2349 Node* object = environment()->Pop(); |
2334 Node* store = BuildKeyedStore(object, key, value); | 2350 Node* store = |
2351 BuildKeyedStore(object, key, value, expr->CountStoreFeedbackId()); | |
2335 environment()->Push(value); | 2352 environment()->Push(value); |
2336 PrepareFrameStateAfterAndBefore(store, expr->AssignmentId(), | 2353 PrepareFrameStateAfterAndBefore(store, expr->AssignmentId(), |
2337 OutputFrameStateCombine::Ignore(), | 2354 OutputFrameStateCombine::Ignore(), |
2338 frame_state_before_store); | 2355 frame_state_before_store); |
2339 environment()->Pop(); | 2356 environment()->Pop(); |
2340 break; | 2357 break; |
2341 } | 2358 } |
2342 } | 2359 } |
2343 | 2360 |
2344 // Restore old value for postfix expressions. | 2361 // Restore old value for postfix expressions. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2733 BailoutId bailout_id, | 2750 BailoutId bailout_id, |
2734 const VectorSlotPair& feedback, | 2751 const VectorSlotPair& feedback, |
2735 ContextualMode contextual_mode) { | 2752 ContextualMode contextual_mode) { |
2736 Node* the_hole = jsgraph()->TheHoleConstant(); | 2753 Node* the_hole = jsgraph()->TheHoleConstant(); |
2737 VariableMode mode = variable->mode(); | 2754 VariableMode mode = variable->mode(); |
2738 switch (variable->location()) { | 2755 switch (variable->location()) { |
2739 case Variable::UNALLOCATED: { | 2756 case Variable::UNALLOCATED: { |
2740 // Global var, const, or let variable. | 2757 // Global var, const, or let variable. |
2741 Node* global = BuildLoadGlobalObject(); | 2758 Node* global = BuildLoadGlobalObject(); |
2742 Handle<Name> name = variable->name(); | 2759 Handle<Name> name = variable->name(); |
2743 Node* node = BuildNamedLoad(global, name, feedback, contextual_mode); | 2760 Node* node = BuildNamedLoad(global, name, feedback, |
2761 TypeFeedbackId::None(), contextual_mode); | |
2744 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); | 2762 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); |
2745 return node; | 2763 return node; |
2746 } | 2764 } |
2747 case Variable::PARAMETER: | 2765 case Variable::PARAMETER: |
2748 case Variable::LOCAL: { | 2766 case Variable::LOCAL: { |
2749 // Local var, const, or let variable. | 2767 // Local var, const, or let variable. |
2750 Node* value = environment()->Lookup(variable); | 2768 Node* value = environment()->Lookup(variable); |
2751 if (mode == CONST_LEGACY) { | 2769 if (mode == CONST_LEGACY) { |
2752 // Perform check for uninitialized legacy const variables. | 2770 // Perform check for uninitialized legacy const variables. |
2753 if (value->op() == the_hole->op()) { | 2771 if (value->op() == the_hole->op()) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2840 Node* AstGraphBuilder::BuildVariableAssignment( | 2858 Node* AstGraphBuilder::BuildVariableAssignment( |
2841 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, | 2859 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, |
2842 OutputFrameStateCombine combine) { | 2860 OutputFrameStateCombine combine) { |
2843 Node* the_hole = jsgraph()->TheHoleConstant(); | 2861 Node* the_hole = jsgraph()->TheHoleConstant(); |
2844 VariableMode mode = variable->mode(); | 2862 VariableMode mode = variable->mode(); |
2845 switch (variable->location()) { | 2863 switch (variable->location()) { |
2846 case Variable::UNALLOCATED: { | 2864 case Variable::UNALLOCATED: { |
2847 // Global var, const, or let variable. | 2865 // Global var, const, or let variable. |
2848 Node* global = BuildLoadGlobalObject(); | 2866 Node* global = BuildLoadGlobalObject(); |
2849 Handle<Name> name = variable->name(); | 2867 Handle<Name> name = variable->name(); |
2850 Node* store = BuildNamedStore(global, name, value); | 2868 Node* store = |
2869 BuildNamedStore(global, name, value, TypeFeedbackId::None()); | |
2851 PrepareFrameState(store, bailout_id, combine); | 2870 PrepareFrameState(store, bailout_id, combine); |
2852 return store; | 2871 return store; |
2853 } | 2872 } |
2854 case Variable::PARAMETER: | 2873 case Variable::PARAMETER: |
2855 case Variable::LOCAL: | 2874 case Variable::LOCAL: |
2856 // Local var, const, or let variable. | 2875 // Local var, const, or let variable. |
2857 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { | 2876 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { |
2858 // Perform an initialization check for legacy const variables. | 2877 // Perform an initialization check for legacy const variables. |
2859 Node* current = environment()->Lookup(variable); | 2878 Node* current = environment()->Lookup(variable); |
2860 if (current->op() != the_hole->op()) { | 2879 if (current->op() != the_hole->op()) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2936 Node* store = NewNode(op, value, current_context(), name, language); | 2955 Node* store = NewNode(op, value, current_context(), name, language); |
2937 PrepareFrameState(store, bailout_id, combine); | 2956 PrepareFrameState(store, bailout_id, combine); |
2938 return store; | 2957 return store; |
2939 } | 2958 } |
2940 } | 2959 } |
2941 UNREACHABLE(); | 2960 UNREACHABLE(); |
2942 return NULL; | 2961 return NULL; |
2943 } | 2962 } |
2944 | 2963 |
2945 | 2964 |
2965 static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node, | |
2966 TypeFeedbackId id) { | |
2967 if (js_type_feedback) js_type_feedback->Record(node, id); | |
2968 return node; | |
2969 } | |
2970 | |
2971 | |
2946 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, | 2972 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, |
2947 const VectorSlotPair& feedback) { | 2973 const VectorSlotPair& feedback, |
2974 TypeFeedbackId id) { | |
2948 const Operator* op = javascript()->LoadProperty(feedback); | 2975 const Operator* op = javascript()->LoadProperty(feedback); |
2949 return NewNode(op, object, key); | 2976 return Record(js_type_feedback_, NewNode(op, object, key), id); |
2950 } | 2977 } |
2951 | 2978 |
2952 | 2979 |
2953 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, | 2980 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, |
2954 const VectorSlotPair& feedback, | 2981 const VectorSlotPair& feedback, |
2955 ContextualMode mode) { | 2982 TypeFeedbackId id, ContextualMode mode) { |
2956 const Operator* op = | 2983 const Operator* op = |
2957 javascript()->LoadNamed(MakeUnique(name), feedback, mode); | 2984 javascript()->LoadNamed(MakeUnique(name), feedback, mode); |
2958 return NewNode(op, object); | 2985 return Record(js_type_feedback_, NewNode(op, object), id); |
2959 } | 2986 } |
2960 | 2987 |
2961 | 2988 |
2962 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value) { | 2989 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, |
2990 TypeFeedbackId id) { | |
2963 const Operator* op = javascript()->StoreProperty(language_mode()); | 2991 const Operator* op = javascript()->StoreProperty(language_mode()); |
2964 return NewNode(op, object, key, value); | 2992 return Record(js_type_feedback_, NewNode(op, object, key, value), id); |
2965 } | 2993 } |
2966 | 2994 |
2967 | 2995 |
2968 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, | 2996 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, |
2969 Node* value) { | 2997 Node* value, TypeFeedbackId id) { |
2970 const Operator* op = | 2998 const Operator* op = |
2971 javascript()->StoreNamed(language_mode(), MakeUnique(name)); | 2999 javascript()->StoreNamed(language_mode(), MakeUnique(name)); |
2972 return NewNode(op, object, value); | 3000 return Record(js_type_feedback_, NewNode(op, object, value), id); |
2973 } | 3001 } |
2974 | 3002 |
2975 | 3003 |
2976 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { | 3004 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { |
2977 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 3005 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, |
2978 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); | 3006 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); |
2979 } | 3007 } |
2980 | 3008 |
2981 | 3009 |
2982 Node* AstGraphBuilder::BuildLoadBuiltinsObject() { | 3010 Node* AstGraphBuilder::BuildLoadBuiltinsObject() { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3051 Node* name = NewNode(javascript()->ToName(), input); | 3079 Node* name = NewNode(javascript()->ToName(), input); |
3052 PrepareFrameState(name, bailout_id); | 3080 PrepareFrameState(name, bailout_id); |
3053 return name; | 3081 return name; |
3054 } | 3082 } |
3055 | 3083 |
3056 | 3084 |
3057 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, | 3085 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, |
3058 Expression* expr) { | 3086 Expression* expr) { |
3059 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; | 3087 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; |
3060 Handle<Name> name = isolate()->factory()->home_object_symbol(); | 3088 Handle<Name> name = isolate()->factory()->home_object_symbol(); |
3061 Node* store = BuildNamedStore(value, name, home_object); | 3089 Node* store = |
3090 BuildNamedStore(value, name, home_object, TypeFeedbackId::None()); | |
3062 PrepareFrameState(store, BailoutId::None()); | 3091 PrepareFrameState(store, BailoutId::None()); |
3063 return store; | 3092 return store; |
3064 } | 3093 } |
3065 | 3094 |
3066 | 3095 |
3067 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) { | 3096 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) { |
3068 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); | 3097 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); |
3069 Node* call = NewNode(op, exception); | 3098 Node* call = NewNode(op, exception); |
3070 PrepareFrameState(call, bailout_id); | 3099 PrepareFrameState(call, bailout_id); |
3071 return call; | 3100 return call; |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3486 // Phi does not exist yet, introduce one. | 3515 // Phi does not exist yet, introduce one. |
3487 value = NewPhi(inputs, value, control); | 3516 value = NewPhi(inputs, value, control); |
3488 value->ReplaceInput(inputs - 1, other); | 3517 value->ReplaceInput(inputs - 1, other); |
3489 } | 3518 } |
3490 return value; | 3519 return value; |
3491 } | 3520 } |
3492 | 3521 |
3493 } // namespace compiler | 3522 } // namespace compiler |
3494 } // namespace internal | 3523 } // namespace internal |
3495 } // namespace v8 | 3524 } // namespace v8 |
OLD | NEW |