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

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

Issue 1405503002: VectorICs: use a vector slot to aid in array literal processing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Code comments. Created 5 years, 2 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/ast-numbering.cc ('k') | src/compiler/js-generic-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/js-type-feedback.h"
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 VisitForValue(property->value()); 1904 VisitForValue(property->value());
1905 BuildSetHomeObject(environment()->Top(), home_object, property); 1905 BuildSetHomeObject(environment()->Top(), home_object, property);
1906 } 1906 }
1907 } 1907 }
1908 1908
1909 1909
1910 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { 1910 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
1911 Node* closure = GetFunctionClosure(); 1911 Node* closure = GetFunctionClosure();
1912 1912
1913 // Create node to deep-copy the literal boilerplate. 1913 // Create node to deep-copy the literal boilerplate.
1914 expr->BuildConstantElements(isolate());
1915 Node* literals_array = 1914 Node* literals_array =
1916 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 1915 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
1917 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 1916 Node* literal_index = jsgraph()->Constant(expr->literal_index());
1918 Node* constants = jsgraph()->Constant(expr->constant_elements()); 1917 Node* constants = jsgraph()->Constant(expr->constant_elements());
1919 const Operator* op = 1918 const Operator* op =
1920 javascript()->CreateLiteralArray(expr->ComputeFlags(true)); 1919 javascript()->CreateLiteralArray(expr->ComputeFlags(true));
1921 Node* literal = NewNode(op, literals_array, literal_index, constants); 1920 Node* literal = NewNode(op, literals_array, literal_index, constants);
1922 PrepareFrameState(literal, expr->CreateLiteralId(), 1921 PrepareFrameState(literal, expr->CreateLiteralId(),
1923 OutputFrameStateCombine::Push()); 1922 OutputFrameStateCombine::Push());
1924 1923
1925 // The array and the literal index are both expected on the operand stack 1924 // The array and the literal index are both expected on the operand stack
1926 // during computation of the element values. 1925 // during computation of the element values.
1927 environment()->Push(literal); 1926 environment()->Push(literal);
1928 environment()->Push(literal_index); 1927 environment()->Push(literal_index);
1929 1928
1930 // Create nodes to evaluate all the non-constant subexpressions and to store 1929 // Create nodes to evaluate all the non-constant subexpressions and to store
1931 // them into the newly cloned array. 1930 // them into the newly cloned array.
1932 int array_index = 0; 1931 int array_index = 0;
1933 for (; array_index < expr->values()->length(); array_index++) { 1932 for (; array_index < expr->values()->length(); array_index++) {
1934 Expression* subexpr = expr->values()->at(array_index); 1933 Expression* subexpr = expr->values()->at(array_index);
1935 if (subexpr->IsSpread()) break; 1934 if (subexpr->IsSpread()) break;
1936 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1935 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1937 1936
1938 VisitForValue(subexpr); 1937 VisitForValue(subexpr);
1939 { 1938 {
1940 FrameStateBeforeAndAfter states(this, subexpr->id()); 1939 FrameStateBeforeAndAfter states(this, subexpr->id());
1940 VectorSlotPair pair = CreateVectorSlotPair(expr->LiteralFeedbackSlot());
1941 Node* value = environment()->Pop(); 1941 Node* value = environment()->Pop();
1942 Node* index = jsgraph()->Constant(array_index); 1942 Node* index = jsgraph()->Constant(array_index);
1943 // TODO(turbofan): More efficient code could be generated here. Consider 1943 Node* store =
1944 // that the store will be generic because we don't have a feedback vector 1944 BuildKeyedStore(literal, index, value, pair, TypeFeedbackId::None());
1945 // slot.
1946 Node* store = BuildKeyedStore(literal, index, value, VectorSlotPair(),
1947 TypeFeedbackId::None());
1948 states.AddToNode(store, expr->GetIdForElement(array_index), 1945 states.AddToNode(store, expr->GetIdForElement(array_index),
1949 OutputFrameStateCombine::Ignore()); 1946 OutputFrameStateCombine::Ignore());
1950 } 1947 }
1951 } 1948 }
1952 1949
1953 // In case the array literal contains spread expressions it has two parts. The 1950 // In case the array literal contains spread expressions it has two parts. The
1954 // first part is the "static" array which has a literal index is handled 1951 // first part is the "static" array which has a literal index is handled
1955 // above. The second part is the part after the first spread expression 1952 // above. The second part is the part after the first spread expression
1956 // (inclusive) and these elements gets appended to the array. Note that the 1953 // (inclusive) and these elements gets appended to the array. Note that the
1957 // number elements an iterable produces is unknown ahead of time. 1954 // number elements an iterable produces is unknown ahead of time.
(...skipping 2330 matching lines...) Expand 10 before | Expand all | Expand 10 after
4288 // Phi does not exist yet, introduce one. 4285 // Phi does not exist yet, introduce one.
4289 value = NewPhi(inputs, value, control); 4286 value = NewPhi(inputs, value, control);
4290 value->ReplaceInput(inputs - 1, other); 4287 value->ReplaceInput(inputs - 1, other);
4291 } 4288 }
4292 return value; 4289 return value;
4293 } 4290 }
4294 4291
4295 } // namespace compiler 4292 } // namespace compiler
4296 } // namespace internal 4293 } // namespace internal
4297 } // namespace v8 4294 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast-numbering.cc ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698