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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1021713005: [turbofan]: Integrate basic type feedback for property accesses. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/compiler/ast-graph-builder.h ('k') | src/compiler/js-intrinsic-lowering.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 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
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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1659 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1657 // Fall through. 1660 // Fall through.
1658 case ObjectLiteral::Property::COMPUTED: { 1661 case ObjectLiteral::Property::COMPUTED: {
1659 // It is safe to use [[Put]] here because the boilerplate already 1662 // It is safe to use [[Put]] here because the boilerplate already
1660 // contains computed properties with an uninitialized value. 1663 // contains computed properties with an uninitialized value.
1661 if (key->value()->IsInternalizedString()) { 1664 if (key->value()->IsInternalizedString()) {
1662 if (property->emit_store()) { 1665 if (property->emit_store()) {
1663 VisitForValue(property->value()); 1666 VisitForValue(property->value());
1664 Node* value = environment()->Pop(); 1667 Node* value = environment()->Pop();
1665 Handle<Name> name = key->AsPropertyName(); 1668 Handle<Name> name = key->AsPropertyName();
1666 Node* store = BuildNamedStore(literal, name, value); 1669 Node* store =
1670 BuildNamedStore(literal, name, value, TypeFeedbackId::None());
1667 PrepareFrameState(store, key->id()); 1671 PrepareFrameState(store, key->id());
1668 BuildSetHomeObject(value, literal, property->value()); 1672 BuildSetHomeObject(value, literal, property->value());
1669 } else { 1673 } else {
1670 VisitForEffect(property->value()); 1674 VisitForEffect(property->value());
1671 } 1675 }
1672 break; 1676 break;
1673 } 1677 }
1674 environment()->Push(literal); // Duplicate receiver. 1678 environment()->Push(literal); // Duplicate receiver.
1675 VisitForValue(property->key()); 1679 VisitForValue(property->key());
1676 VisitForValue(property->value()); 1680 VisitForValue(property->value());
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 // them into the newly cloned array. 1835 // them into the newly cloned array.
1832 for (int i = 0; i < expr->values()->length(); i++) { 1836 for (int i = 0; i < expr->values()->length(); i++) {
1833 Expression* subexpr = expr->values()->at(i); 1837 Expression* subexpr = expr->values()->at(i);
1834 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1838 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1835 1839
1836 VisitForValue(subexpr); 1840 VisitForValue(subexpr);
1837 Node* frame_state_before = environment()->Checkpoint( 1841 Node* frame_state_before = environment()->Checkpoint(
1838 subexpr->id(), OutputFrameStateCombine::PokeAt(0)); 1842 subexpr->id(), OutputFrameStateCombine::PokeAt(0));
1839 Node* value = environment()->Pop(); 1843 Node* value = environment()->Pop();
1840 Node* index = jsgraph()->Constant(i); 1844 Node* index = jsgraph()->Constant(i);
1841 Node* store = BuildKeyedStore(literal, index, value); 1845 Node* store =
1846 BuildKeyedStore(literal, index, value, TypeFeedbackId::None());
1842 PrepareFrameStateAfterAndBefore(store, expr->GetIdForElement(i), 1847 PrepareFrameStateAfterAndBefore(store, expr->GetIdForElement(i),
1843 OutputFrameStateCombine::Ignore(), 1848 OutputFrameStateCombine::Ignore(),
1844 frame_state_before); 1849 frame_state_before);
1845 } 1850 }
1846 1851
1847 environment()->Pop(); // Array literal index. 1852 environment()->Pop(); // Array literal index.
1848 ast_context()->ProduceValue(environment()->Pop()); 1853 ast_context()->ProduceValue(environment()->Pop());
1849 } 1854 }
1850 1855
1851 1856
(...skipping 11 matching lines...) Expand all
1863 Variable* var = expr->AsVariableProxy()->var(); 1868 Variable* var = expr->AsVariableProxy()->var();
1864 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); 1869 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id);
1865 break; 1870 break;
1866 } 1871 }
1867 case NAMED_PROPERTY: { 1872 case NAMED_PROPERTY: {
1868 environment()->Push(value); 1873 environment()->Push(value);
1869 VisitForValue(property->obj()); 1874 VisitForValue(property->obj());
1870 Node* object = environment()->Pop(); 1875 Node* object = environment()->Pop();
1871 value = environment()->Pop(); 1876 value = environment()->Pop();
1872 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 1877 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1873 Node* store = BuildNamedStore(object, name, value); 1878 Node* store =
1879 BuildNamedStore(object, name, value, TypeFeedbackId::None());
1874 PrepareFrameState(store, bailout_id); 1880 PrepareFrameState(store, bailout_id);
1875 break; 1881 break;
1876 } 1882 }
1877 case KEYED_PROPERTY: { 1883 case KEYED_PROPERTY: {
1878 environment()->Push(value); 1884 environment()->Push(value);
1879 VisitForValue(property->obj()); 1885 VisitForValue(property->obj());
1880 VisitForValue(property->key()); 1886 VisitForValue(property->key());
1881 Node* key = environment()->Pop(); 1887 Node* key = environment()->Pop();
1882 Node* object = environment()->Pop(); 1888 Node* object = environment()->Pop();
1883 value = environment()->Pop(); 1889 value = environment()->Pop();
1884 Node* store = BuildKeyedStore(object, key, value); 1890 Node* store = BuildKeyedStore(object, key, value, TypeFeedbackId::None());
1885 // TODO(jarin) Provide a real frame state before. 1891 // TODO(jarin) Provide a real frame state before.
1886 PrepareFrameStateAfterAndBefore(store, bailout_id, 1892 PrepareFrameStateAfterAndBefore(store, bailout_id,
1887 OutputFrameStateCombine::Ignore(), 1893 OutputFrameStateCombine::Ignore(),
1888 jsgraph()->EmptyFrameState()); 1894 jsgraph()->EmptyFrameState());
1889 break; 1895 break;
1890 } 1896 }
1891 } 1897 }
1892 } 1898 }
1893 1899
1894 1900
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 VectorSlotPair pair = 1932 VectorSlotPair pair =
1927 CreateVectorSlotPair(proxy->VariableFeedbackSlot()); 1933 CreateVectorSlotPair(proxy->VariableFeedbackSlot());
1928 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair); 1934 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair);
1929 break; 1935 break;
1930 } 1936 }
1931 case NAMED_PROPERTY: { 1937 case NAMED_PROPERTY: {
1932 Node* object = environment()->Top(); 1938 Node* object = environment()->Top();
1933 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 1939 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1934 VectorSlotPair pair = 1940 VectorSlotPair pair =
1935 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 1941 CreateVectorSlotPair(property->PropertyFeedbackSlot());
1936 old_value = BuildNamedLoad(object, name, pair); 1942 old_value =
1943 BuildNamedLoad(object, name, pair, property->PropertyFeedbackId());
1937 PrepareFrameState(old_value, property->LoadId(), 1944 PrepareFrameState(old_value, property->LoadId(),
1938 OutputFrameStateCombine::Push()); 1945 OutputFrameStateCombine::Push());
1939 break; 1946 break;
1940 } 1947 }
1941 case KEYED_PROPERTY: { 1948 case KEYED_PROPERTY: {
1942 Node* key = environment()->Top(); 1949 Node* key = environment()->Top();
1943 Node* object = environment()->Peek(1); 1950 Node* object = environment()->Peek(1);
1944 VectorSlotPair pair = 1951 VectorSlotPair pair =
1945 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 1952 CreateVectorSlotPair(property->PropertyFeedbackSlot());
1946 old_value = BuildKeyedLoad(object, key, pair); 1953 old_value =
1954 BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId());
1947 PrepareFrameState(old_value, property->LoadId(), 1955 PrepareFrameState(old_value, property->LoadId(),
1948 OutputFrameStateCombine::Push()); 1956 OutputFrameStateCombine::Push());
1949 break; 1957 break;
1950 } 1958 }
1951 } 1959 }
1952 environment()->Push(old_value); 1960 environment()->Push(old_value);
1953 VisitForValue(expr->value()); 1961 VisitForValue(expr->value());
1954 Node* frame_state_before = environment()->Checkpoint(expr->value()->id()); 1962 Node* frame_state_before = environment()->Checkpoint(expr->value()->id());
1955 Node* right = environment()->Pop(); 1963 Node* right = environment()->Pop();
1956 Node* left = environment()->Pop(); 1964 Node* left = environment()->Pop();
(...skipping 24 matching lines...) Expand all
1981 switch (assign_type) { 1989 switch (assign_type) {
1982 case VARIABLE: { 1990 case VARIABLE: {
1983 Variable* variable = expr->target()->AsVariableProxy()->var(); 1991 Variable* variable = expr->target()->AsVariableProxy()->var();
1984 BuildVariableAssignment(variable, value, expr->op(), expr->id(), 1992 BuildVariableAssignment(variable, value, expr->op(), expr->id(),
1985 ast_context()->GetStateCombine()); 1993 ast_context()->GetStateCombine());
1986 break; 1994 break;
1987 } 1995 }
1988 case NAMED_PROPERTY: { 1996 case NAMED_PROPERTY: {
1989 Node* object = environment()->Pop(); 1997 Node* object = environment()->Pop();
1990 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 1998 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1991 Node* store = BuildNamedStore(object, name, value); 1999 Node* store =
2000 BuildNamedStore(object, name, value, expr->AssignmentFeedbackId());
1992 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine()); 2001 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine());
1993 break; 2002 break;
1994 } 2003 }
1995 case KEYED_PROPERTY: { 2004 case KEYED_PROPERTY: {
1996 Node* key = environment()->Pop(); 2005 Node* key = environment()->Pop();
1997 Node* object = environment()->Pop(); 2006 Node* object = environment()->Pop();
1998 Node* store = BuildKeyedStore(object, key, value); 2007 Node* store =
2008 BuildKeyedStore(object, key, value, expr->AssignmentFeedbackId());
1999 PrepareFrameStateAfterAndBefore(store, expr->id(), 2009 PrepareFrameStateAfterAndBefore(store, expr->id(),
2000 ast_context()->GetStateCombine(), 2010 ast_context()->GetStateCombine(),
2001 frame_state_before_store); 2011 frame_state_before_store);
2002 break; 2012 break;
2003 } 2013 }
2004 } 2014 }
2005 2015
2006 ast_context()->ProduceValue(value); 2016 ast_context()->ProduceValue(value);
2007 } 2017 }
2008 2018
(...skipping 13 matching lines...) Expand all
2022 } 2032 }
2023 2033
2024 2034
2025 void AstGraphBuilder::VisitProperty(Property* expr) { 2035 void AstGraphBuilder::VisitProperty(Property* expr) {
2026 Node* value; 2036 Node* value;
2027 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot()); 2037 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot());
2028 if (expr->key()->IsPropertyName()) { 2038 if (expr->key()->IsPropertyName()) {
2029 VisitForValue(expr->obj()); 2039 VisitForValue(expr->obj());
2030 Node* object = environment()->Pop(); 2040 Node* object = environment()->Pop();
2031 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName(); 2041 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName();
2032 value = BuildNamedLoad(object, name, pair); 2042 value = BuildNamedLoad(object, name, pair, expr->PropertyFeedbackId());
2033 } else { 2043 } else {
2034 VisitForValue(expr->obj()); 2044 VisitForValue(expr->obj());
2035 VisitForValue(expr->key()); 2045 VisitForValue(expr->key());
2036 Node* key = environment()->Pop(); 2046 Node* key = environment()->Pop();
2037 Node* object = environment()->Pop(); 2047 Node* object = environment()->Pop();
2038 value = BuildKeyedLoad(object, key, pair); 2048 value = BuildKeyedLoad(object, key, pair, expr->PropertyFeedbackId());
2039 } 2049 }
2040 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2050 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2041 ast_context()->ProduceValue(value); 2051 ast_context()->ProduceValue(value);
2042 } 2052 }
2043 2053
2044 2054
2045 void AstGraphBuilder::VisitCall(Call* expr) { 2055 void AstGraphBuilder::VisitCall(Call* expr) {
2046 Expression* callee = expr->expression(); 2056 Expression* callee = expr->expression();
2047 Call::CallType call_type = expr->GetCallType(isolate()); 2057 Call::CallType call_type = expr->GetCallType(isolate());
2048 2058
(...skipping 27 matching lines...) Expand all
2076 break; 2086 break;
2077 } 2087 }
2078 case Call::PROPERTY_CALL: { 2088 case Call::PROPERTY_CALL: {
2079 Property* property = callee->AsProperty(); 2089 Property* property = callee->AsProperty();
2080 VisitForValue(property->obj()); 2090 VisitForValue(property->obj());
2081 Node* object = environment()->Top(); 2091 Node* object = environment()->Top();
2082 VectorSlotPair pair = 2092 VectorSlotPair pair =
2083 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2093 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2084 if (property->key()->IsPropertyName()) { 2094 if (property->key()->IsPropertyName()) {
2085 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2095 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2086 callee_value = BuildNamedLoad(object, name, pair); 2096 callee_value =
2097 BuildNamedLoad(object, name, pair, property->PropertyFeedbackId());
2087 } else { 2098 } else {
2088 VisitForValue(property->key()); 2099 VisitForValue(property->key());
2089 Node* key = environment()->Pop(); 2100 Node* key = environment()->Pop();
2090 callee_value = BuildKeyedLoad(object, key, pair); 2101 callee_value =
2102 BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId());
2091 } 2103 }
2092 PrepareFrameState(callee_value, property->LoadId(), 2104 PrepareFrameState(callee_value, property->LoadId(),
2093 OutputFrameStateCombine::Push()); 2105 OutputFrameStateCombine::Push());
2094 receiver_value = environment()->Pop(); 2106 receiver_value = environment()->Pop();
2095 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an 2107 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an
2096 // object for sloppy callees. This could also be modeled explicitly here, 2108 // object for sloppy callees. This could also be modeled explicitly here,
2097 // thereby obsoleting the need for a flag to the call operator. 2109 // thereby obsoleting the need for a flag to the call operator.
2098 flags = CALL_AS_METHOD; 2110 flags = CALL_AS_METHOD;
2099 break; 2111 break;
2100 } 2112 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 2188
2177 2189
2178 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { 2190 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
2179 Handle<String> name = expr->name(); 2191 Handle<String> name = expr->name();
2180 2192
2181 // The callee and the receiver both have to be pushed onto the operand stack 2193 // The callee and the receiver both have to be pushed onto the operand stack
2182 // before arguments are being evaluated. 2194 // before arguments are being evaluated.
2183 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 2195 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
2184 Node* receiver_value = BuildLoadBuiltinsObject(); 2196 Node* receiver_value = BuildLoadBuiltinsObject();
2185 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); 2197 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot());
2186 Node* callee_value = BuildNamedLoad(receiver_value, name, pair); 2198 Node* callee_value =
2199 BuildNamedLoad(receiver_value, name, pair, expr->CallRuntimeFeedbackId());
2187 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft 2200 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft
2188 // refuses to optimize functions with jsruntime calls). 2201 // refuses to optimize functions with jsruntime calls).
2189 PrepareFrameState(callee_value, BailoutId::None(), 2202 PrepareFrameState(callee_value, BailoutId::None(),
2190 OutputFrameStateCombine::Push()); 2203 OutputFrameStateCombine::Push());
2191 environment()->Push(callee_value); 2204 environment()->Push(callee_value);
2192 environment()->Push(receiver_value); 2205 environment()->Push(receiver_value);
2193 2206
2194 // Evaluate all arguments to the JS runtime call. 2207 // Evaluate all arguments to the JS runtime call.
2195 ZoneList<Expression*>* args = expr->arguments(); 2208 ZoneList<Expression*>* args = expr->arguments();
2196 VisitForValues(args); 2209 VisitForValues(args);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2264 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair); 2277 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair);
2265 stack_depth = 0; 2278 stack_depth = 0;
2266 break; 2279 break;
2267 } 2280 }
2268 case NAMED_PROPERTY: { 2281 case NAMED_PROPERTY: {
2269 VisitForValue(property->obj()); 2282 VisitForValue(property->obj());
2270 Node* object = environment()->Top(); 2283 Node* object = environment()->Top();
2271 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2284 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2272 VectorSlotPair pair = 2285 VectorSlotPair pair =
2273 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2286 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2274 old_value = BuildNamedLoad(object, name, pair); 2287 old_value =
2288 BuildNamedLoad(object, name, pair, property->PropertyFeedbackId());
2275 PrepareFrameState(old_value, property->LoadId(), 2289 PrepareFrameState(old_value, property->LoadId(),
2276 OutputFrameStateCombine::Push()); 2290 OutputFrameStateCombine::Push());
2277 stack_depth = 1; 2291 stack_depth = 1;
2278 break; 2292 break;
2279 } 2293 }
2280 case KEYED_PROPERTY: { 2294 case KEYED_PROPERTY: {
2281 VisitForValue(property->obj()); 2295 VisitForValue(property->obj());
2282 VisitForValue(property->key()); 2296 VisitForValue(property->key());
2283 Node* key = environment()->Top(); 2297 Node* key = environment()->Top();
2284 Node* object = environment()->Peek(1); 2298 Node* object = environment()->Peek(1);
2285 VectorSlotPair pair = 2299 VectorSlotPair pair =
2286 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2300 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2287 old_value = BuildKeyedLoad(object, key, pair); 2301 old_value =
2302 BuildKeyedLoad(object, key, pair, property->PropertyFeedbackId());
2288 PrepareFrameState(old_value, property->LoadId(), 2303 PrepareFrameState(old_value, property->LoadId(),
2289 OutputFrameStateCombine::Push()); 2304 OutputFrameStateCombine::Push());
2290 stack_depth = 2; 2305 stack_depth = 2;
2291 break; 2306 break;
2292 } 2307 }
2293 } 2308 }
2294 2309
2295 // Convert old value into a number. 2310 // Convert old value into a number.
2296 old_value = NewNode(javascript()->ToNumber(), old_value); 2311 old_value = NewNode(javascript()->ToNumber(), old_value);
2297 PrepareFrameState(old_value, expr->ToNumberId(), 2312 PrepareFrameState(old_value, expr->ToNumberId(),
(...skipping 22 matching lines...) Expand all
2320 Variable* variable = expr->expression()->AsVariableProxy()->var(); 2335 Variable* variable = expr->expression()->AsVariableProxy()->var();
2321 environment()->Push(value); 2336 environment()->Push(value);
2322 BuildVariableAssignment(variable, value, expr->op(), 2337 BuildVariableAssignment(variable, value, expr->op(),
2323 expr->AssignmentId()); 2338 expr->AssignmentId());
2324 environment()->Pop(); 2339 environment()->Pop();
2325 break; 2340 break;
2326 } 2341 }
2327 case NAMED_PROPERTY: { 2342 case NAMED_PROPERTY: {
2328 Node* object = environment()->Pop(); 2343 Node* object = environment()->Pop();
2329 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2344 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2330 Node* store = BuildNamedStore(object, name, value); 2345 Node* store =
2346 BuildNamedStore(object, name, value, expr->CountStoreFeedbackId());
2331 environment()->Push(value); 2347 environment()->Push(value);
2332 PrepareFrameState(store, expr->AssignmentId()); 2348 PrepareFrameState(store, expr->AssignmentId());
2333 environment()->Pop(); 2349 environment()->Pop();
2334 break; 2350 break;
2335 } 2351 }
2336 case KEYED_PROPERTY: { 2352 case KEYED_PROPERTY: {
2337 Node* key = environment()->Pop(); 2353 Node* key = environment()->Pop();
2338 Node* object = environment()->Pop(); 2354 Node* object = environment()->Pop();
2339 Node* store = BuildKeyedStore(object, key, value); 2355 Node* store =
2356 BuildKeyedStore(object, key, value, expr->CountStoreFeedbackId());
2340 environment()->Push(value); 2357 environment()->Push(value);
2341 PrepareFrameStateAfterAndBefore(store, expr->AssignmentId(), 2358 PrepareFrameStateAfterAndBefore(store, expr->AssignmentId(),
2342 OutputFrameStateCombine::Ignore(), 2359 OutputFrameStateCombine::Ignore(),
2343 frame_state_before_store); 2360 frame_state_before_store);
2344 environment()->Pop(); 2361 environment()->Pop();
2345 break; 2362 break;
2346 } 2363 }
2347 } 2364 }
2348 2365
2349 // Restore old value for postfix expressions. 2366 // Restore old value for postfix expressions.
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 BailoutId bailout_id, 2755 BailoutId bailout_id,
2739 const VectorSlotPair& feedback, 2756 const VectorSlotPair& feedback,
2740 ContextualMode contextual_mode) { 2757 ContextualMode contextual_mode) {
2741 Node* the_hole = jsgraph()->TheHoleConstant(); 2758 Node* the_hole = jsgraph()->TheHoleConstant();
2742 VariableMode mode = variable->mode(); 2759 VariableMode mode = variable->mode();
2743 switch (variable->location()) { 2760 switch (variable->location()) {
2744 case Variable::UNALLOCATED: { 2761 case Variable::UNALLOCATED: {
2745 // Global var, const, or let variable. 2762 // Global var, const, or let variable.
2746 Node* global = BuildLoadGlobalObject(); 2763 Node* global = BuildLoadGlobalObject();
2747 Handle<Name> name = variable->name(); 2764 Handle<Name> name = variable->name();
2748 Node* node = BuildNamedLoad(global, name, feedback, contextual_mode); 2765 Node* node = BuildNamedLoad(global, name, feedback,
2766 TypeFeedbackId::None(), contextual_mode);
2749 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); 2767 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push());
2750 return node; 2768 return node;
2751 } 2769 }
2752 case Variable::PARAMETER: 2770 case Variable::PARAMETER:
2753 case Variable::LOCAL: { 2771 case Variable::LOCAL: {
2754 // Local var, const, or let variable. 2772 // Local var, const, or let variable.
2755 Node* value = environment()->Lookup(variable); 2773 Node* value = environment()->Lookup(variable);
2756 if (mode == CONST_LEGACY) { 2774 if (mode == CONST_LEGACY) {
2757 // Perform check for uninitialized legacy const variables. 2775 // Perform check for uninitialized legacy const variables.
2758 if (value->op() == the_hole->op()) { 2776 if (value->op() == the_hole->op()) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 Node* AstGraphBuilder::BuildVariableAssignment( 2863 Node* AstGraphBuilder::BuildVariableAssignment(
2846 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, 2864 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
2847 OutputFrameStateCombine combine) { 2865 OutputFrameStateCombine combine) {
2848 Node* the_hole = jsgraph()->TheHoleConstant(); 2866 Node* the_hole = jsgraph()->TheHoleConstant();
2849 VariableMode mode = variable->mode(); 2867 VariableMode mode = variable->mode();
2850 switch (variable->location()) { 2868 switch (variable->location()) {
2851 case Variable::UNALLOCATED: { 2869 case Variable::UNALLOCATED: {
2852 // Global var, const, or let variable. 2870 // Global var, const, or let variable.
2853 Node* global = BuildLoadGlobalObject(); 2871 Node* global = BuildLoadGlobalObject();
2854 Handle<Name> name = variable->name(); 2872 Handle<Name> name = variable->name();
2855 Node* store = BuildNamedStore(global, name, value); 2873 Node* store =
2874 BuildNamedStore(global, name, value, TypeFeedbackId::None());
2856 PrepareFrameState(store, bailout_id, combine); 2875 PrepareFrameState(store, bailout_id, combine);
2857 return store; 2876 return store;
2858 } 2877 }
2859 case Variable::PARAMETER: 2878 case Variable::PARAMETER:
2860 case Variable::LOCAL: 2879 case Variable::LOCAL:
2861 // Local var, const, or let variable. 2880 // Local var, const, or let variable.
2862 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2881 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2863 // Perform an initialization check for legacy const variables. 2882 // Perform an initialization check for legacy const variables.
2864 Node* current = environment()->Lookup(variable); 2883 Node* current = environment()->Lookup(variable);
2865 if (current->op() != the_hole->op()) { 2884 if (current->op() != the_hole->op()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 Node* store = NewNode(op, value, current_context(), name, language); 2960 Node* store = NewNode(op, value, current_context(), name, language);
2942 PrepareFrameState(store, bailout_id, combine); 2961 PrepareFrameState(store, bailout_id, combine);
2943 return store; 2962 return store;
2944 } 2963 }
2945 } 2964 }
2946 UNREACHABLE(); 2965 UNREACHABLE();
2947 return NULL; 2966 return NULL;
2948 } 2967 }
2949 2968
2950 2969
2970 static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node,
2971 TypeFeedbackId id) {
2972 if (js_type_feedback) js_type_feedback->Record(node, id);
2973 return node;
2974 }
2975
2976
2951 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, 2977 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
2952 const VectorSlotPair& feedback) { 2978 const VectorSlotPair& feedback,
2979 TypeFeedbackId id) {
2953 const Operator* op = javascript()->LoadProperty(feedback); 2980 const Operator* op = javascript()->LoadProperty(feedback);
2954 return NewNode(op, object, key); 2981 return Record(js_type_feedback_, NewNode(op, object, key), id);
2955 } 2982 }
2956 2983
2957 2984
2958 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, 2985 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
2959 const VectorSlotPair& feedback, 2986 const VectorSlotPair& feedback,
2960 ContextualMode mode) { 2987 TypeFeedbackId id, ContextualMode mode) {
2961 const Operator* op = 2988 const Operator* op =
2962 javascript()->LoadNamed(MakeUnique(name), feedback, mode); 2989 javascript()->LoadNamed(MakeUnique(name), feedback, mode);
2963 return NewNode(op, object); 2990 return Record(js_type_feedback_, NewNode(op, object), id);
2964 } 2991 }
2965 2992
2966 2993
2967 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value) { 2994 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value,
2995 TypeFeedbackId id) {
2968 const Operator* op = javascript()->StoreProperty(language_mode()); 2996 const Operator* op = javascript()->StoreProperty(language_mode());
2969 return NewNode(op, object, key, value); 2997 return Record(js_type_feedback_, NewNode(op, object, key, value), id);
2970 } 2998 }
2971 2999
2972 3000
2973 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, 3001 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
2974 Node* value) { 3002 Node* value, TypeFeedbackId id) {
2975 const Operator* op = 3003 const Operator* op =
2976 javascript()->StoreNamed(language_mode(), MakeUnique(name)); 3004 javascript()->StoreNamed(language_mode(), MakeUnique(name));
2977 return NewNode(op, object, value); 3005 return Record(js_type_feedback_, NewNode(op, object, value), id);
2978 } 3006 }
2979 3007
2980 3008
2981 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { 3009 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
2982 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, 3010 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
2983 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); 3011 jsgraph()->IntPtrConstant(offset - kHeapObjectTag));
2984 } 3012 }
2985 3013
2986 3014
2987 Node* AstGraphBuilder::BuildLoadBuiltinsObject() { 3015 Node* AstGraphBuilder::BuildLoadBuiltinsObject() {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 Node* name = NewNode(javascript()->ToName(), input); 3084 Node* name = NewNode(javascript()->ToName(), input);
3057 PrepareFrameState(name, bailout_id); 3085 PrepareFrameState(name, bailout_id);
3058 return name; 3086 return name;
3059 } 3087 }
3060 3088
3061 3089
3062 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, 3090 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object,
3063 Expression* expr) { 3091 Expression* expr) {
3064 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; 3092 if (!FunctionLiteral::NeedsHomeObject(expr)) return value;
3065 Handle<Name> name = isolate()->factory()->home_object_symbol(); 3093 Handle<Name> name = isolate()->factory()->home_object_symbol();
3066 Node* store = BuildNamedStore(value, name, home_object); 3094 Node* store =
3095 BuildNamedStore(value, name, home_object, TypeFeedbackId::None());
3067 PrepareFrameState(store, BailoutId::None()); 3096 PrepareFrameState(store, BailoutId::None());
3068 return store; 3097 return store;
3069 } 3098 }
3070 3099
3071 3100
3072 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) { 3101 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) {
3073 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); 3102 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1);
3074 Node* call = NewNode(op, exception); 3103 Node* call = NewNode(op, exception);
3075 PrepareFrameState(call, bailout_id); 3104 PrepareFrameState(call, bailout_id);
3076 return call; 3105 return call;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3491 // Phi does not exist yet, introduce one. 3520 // Phi does not exist yet, introduce one.
3492 value = NewPhi(inputs, value, control); 3521 value = NewPhi(inputs, value, control);
3493 value->ReplaceInput(inputs - 1, other); 3522 value->ReplaceInput(inputs - 1, other);
3494 } 3523 }
3495 return value; 3524 return value;
3496 } 3525 }
3497 3526
3498 } // namespace compiler 3527 } // namespace compiler
3499 } // namespace internal 3528 } // namespace internal
3500 } // namespace v8 3529 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-intrinsic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698