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

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

Issue 1471893003: [compiler] No need to push literal index in VisitArrayLiteral. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 5 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/crankshaft/hydrogen.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/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 Node* literals_array = 1910 Node* literals_array =
1911 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 1911 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
1912 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 1912 Node* literal_index = jsgraph()->Constant(expr->literal_index());
1913 Node* constants = jsgraph()->Constant(expr->constant_elements()); 1913 Node* constants = jsgraph()->Constant(expr->constant_elements());
1914 const Operator* op = 1914 const Operator* op =
1915 javascript()->CreateLiteralArray(expr->ComputeFlags(true)); 1915 javascript()->CreateLiteralArray(expr->ComputeFlags(true));
1916 Node* literal = NewNode(op, literals_array, literal_index, constants); 1916 Node* literal = NewNode(op, literals_array, literal_index, constants);
1917 PrepareFrameState(literal, expr->CreateLiteralId(), 1917 PrepareFrameState(literal, expr->CreateLiteralId(),
1918 OutputFrameStateCombine::Push()); 1918 OutputFrameStateCombine::Push());
1919 1919
1920 // The array and the literal index are both expected on the operand stack 1920 // The array is expected on the operand stack during computation of the
1921 // during computation of the element values. 1921 // element values.
1922 environment()->Push(literal); 1922 environment()->Push(literal);
1923 environment()->Push(literal_index);
1924 1923
1925 // Create nodes to evaluate all the non-constant subexpressions and to store 1924 // Create nodes to evaluate all the non-constant subexpressions and to store
1926 // them into the newly cloned array. 1925 // them into the newly cloned array.
1927 int array_index = 0; 1926 int array_index = 0;
1928 for (; array_index < expr->values()->length(); array_index++) { 1927 for (; array_index < expr->values()->length(); array_index++) {
1929 Expression* subexpr = expr->values()->at(array_index); 1928 Expression* subexpr = expr->values()->at(array_index);
1930 if (subexpr->IsSpread()) break; 1929 if (subexpr->IsSpread()) break;
1931 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1930 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1932 1931
1933 VisitForValue(subexpr); 1932 VisitForValue(subexpr);
1934 { 1933 {
1935 FrameStateBeforeAndAfter states(this, subexpr->id()); 1934 FrameStateBeforeAndAfter states(this, subexpr->id());
1936 VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot()); 1935 VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot());
1937 Node* value = environment()->Pop(); 1936 Node* value = environment()->Pop();
1938 Node* index = jsgraph()->Constant(array_index); 1937 Node* index = jsgraph()->Constant(array_index);
1939 Node* literal = environment()->Peek(1); 1938 Node* literal = environment()->Top();
1940 Node* store = BuildKeyedStore(literal, index, value, pair); 1939 Node* store = BuildKeyedStore(literal, index, value, pair);
1941 states.AddToNode(store, expr->GetIdForElement(array_index), 1940 states.AddToNode(store, expr->GetIdForElement(array_index),
1942 OutputFrameStateCombine::Ignore()); 1941 OutputFrameStateCombine::Ignore());
1943 } 1942 }
1944 } 1943 }
1945 1944
1946 // In case the array literal contains spread expressions it has two parts. The 1945 // In case the array literal contains spread expressions it has two parts. The
1947 // first part is the "static" array which has a literal index is handled 1946 // first part is the "static" array which has a literal index is handled
1948 // above. The second part is the part after the first spread expression 1947 // above. The second part is the part after the first spread expression
1949 // (inclusive) and these elements gets appended to the array. Note that the 1948 // (inclusive) and these elements gets appended to the array. Note that the
1950 // number elements an iterable produces is unknown ahead of time. 1949 // number elements an iterable produces is unknown ahead of time.
1951 environment()->Pop(); // Array literal index.
1952 for (; array_index < expr->values()->length(); array_index++) { 1950 for (; array_index < expr->values()->length(); array_index++) {
1953 Expression* subexpr = expr->values()->at(array_index); 1951 Expression* subexpr = expr->values()->at(array_index);
1954 Node* result; 1952 Node* result;
1955 1953
1956 if (subexpr->IsSpread()) { 1954 if (subexpr->IsSpread()) {
1957 VisitForValue(subexpr->AsSpread()->expression()); 1955 VisitForValue(subexpr->AsSpread()->expression());
1958 FrameStateBeforeAndAfter states(this, 1956 FrameStateBeforeAndAfter states(this,
1959 subexpr->AsSpread()->expression()->id()); 1957 subexpr->AsSpread()->expression()->id());
1960 Node* iterable = environment()->Pop(); 1958 Node* iterable = environment()->Pop();
1961 Node* array = environment()->Pop(); 1959 Node* array = environment()->Pop();
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after
4309 // Phi does not exist yet, introduce one. 4307 // Phi does not exist yet, introduce one.
4310 value = NewPhi(inputs, value, control); 4308 value = NewPhi(inputs, value, control);
4311 value->ReplaceInput(inputs - 1, other); 4309 value->ReplaceInput(inputs - 1, other);
4312 } 4310 }
4313 return value; 4311 return value;
4314 } 4312 }
4315 4313
4316 } // namespace compiler 4314 } // namespace compiler
4317 } // namespace internal 4315 } // namespace internal
4318 } // namespace v8 4316 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698