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

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

Issue 1158443004: [turbofan] Fix known issue about computed property names. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « no previous file | test/mjsunit/harmony/computed-property-names-deopt.js » ('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 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 // Runtime_CreateObjectLiteralBoilerplate. The second "dynamic" part starts 1881 // Runtime_CreateObjectLiteralBoilerplate. The second "dynamic" part starts
1882 // with the first computed property name and continues with all properties to 1882 // with the first computed property name and continues with all properties to
1883 // its right. All the code from above initializes the static component of the 1883 // its right. All the code from above initializes the static component of the
1884 // object literal, and arranges for the map of the result to reflect the 1884 // object literal, and arranges for the map of the result to reflect the
1885 // static order in which the keys appear. For the dynamic properties, we 1885 // static order in which the keys appear. For the dynamic properties, we
1886 // compile them into a series of "SetOwnProperty" runtime calls. This will 1886 // compile them into a series of "SetOwnProperty" runtime calls. This will
1887 // preserve insertion order. 1887 // preserve insertion order.
1888 for (; property_index < expr->properties()->length(); property_index++) { 1888 for (; property_index < expr->properties()->length(); property_index++) {
1889 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1889 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1890 1890
1891 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1892 environment()->Push(literal); // Duplicate receiver.
1893 VisitForValue(property->value());
1894 Node* value = environment()->Pop();
1895 Node* receiver = environment()->Pop();
1896 const Operator* op =
1897 javascript()->CallRuntime(Runtime::kInternalSetPrototype, 2);
1898 Node* call = NewNode(op, receiver, value);
1899 PrepareFrameState(call, BailoutId::None());
1900 continue;
1901 }
1902
1891 environment()->Push(literal); // Duplicate receiver. 1903 environment()->Push(literal); // Duplicate receiver.
1892 VisitForValue(property->key()); 1904 VisitForValue(property->key());
1893 Node* name = BuildToName(environment()->Pop(), 1905 Node* name = BuildToName(environment()->Pop(),
1894 expr->GetIdForProperty(property_index)); 1906 expr->GetIdForProperty(property_index));
1895 environment()->Push(name); 1907 environment()->Push(name);
1896 // TODO(mstarzinger): For ObjectLiteral::Property::PROTOTYPE the key should
1897 // not be on the operand stack while the value is being evaluated. Come up
1898 // with a repro for this and fix it. Also find a nice way to do so. :)
1899 VisitForValue(property->value()); 1908 VisitForValue(property->value());
1900 Node* value = environment()->Pop(); 1909 Node* value = environment()->Pop();
1901 Node* key = environment()->Pop(); 1910 Node* key = environment()->Pop();
1902 Node* receiver = environment()->Pop(); 1911 Node* receiver = environment()->Pop();
1903 BuildSetHomeObject(value, receiver, property->value()); 1912 BuildSetHomeObject(value, receiver, property->value());
1904 1913
1905 switch (property->kind()) { 1914 switch (property->kind()) {
1906 case ObjectLiteral::Property::CONSTANT: 1915 case ObjectLiteral::Property::CONSTANT:
1907 case ObjectLiteral::Property::COMPUTED: 1916 case ObjectLiteral::Property::COMPUTED:
1908 case ObjectLiteral::Property::MATERIALIZED_LITERAL: { 1917 case ObjectLiteral::Property::MATERIALIZED_LITERAL: {
1909 Node* attr = jsgraph()->Constant(NONE); 1918 Node* attr = jsgraph()->Constant(NONE);
1910 const Operator* op = 1919 const Operator* op =
1911 javascript()->CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4); 1920 javascript()->CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1912 Node* call = NewNode(op, receiver, key, value, attr); 1921 Node* call = NewNode(op, receiver, key, value, attr);
1913 PrepareFrameState(call, BailoutId::None()); 1922 PrepareFrameState(call, BailoutId::None());
1914 break; 1923 break;
1915 } 1924 }
1916 case ObjectLiteral::Property::PROTOTYPE: { 1925 case ObjectLiteral::Property::PROTOTYPE:
1917 const Operator* op = 1926 UNREACHABLE(); // Handled specially above.
1918 javascript()->CallRuntime(Runtime::kInternalSetPrototype, 2);
1919 Node* call = NewNode(op, receiver, value);
1920 PrepareFrameState(call, BailoutId::None());
1921 break; 1927 break;
1922 }
1923 case ObjectLiteral::Property::GETTER: { 1928 case ObjectLiteral::Property::GETTER: {
1924 Node* attr = jsgraph()->Constant(NONE); 1929 Node* attr = jsgraph()->Constant(NONE);
1925 const Operator* op = javascript()->CallRuntime( 1930 const Operator* op = javascript()->CallRuntime(
1926 Runtime::kDefineGetterPropertyUnchecked, 4); 1931 Runtime::kDefineGetterPropertyUnchecked, 4);
1927 Node* call = NewNode(op, receiver, key, value, attr); 1932 Node* call = NewNode(op, receiver, key, value, attr);
1928 PrepareFrameState(call, BailoutId::None()); 1933 PrepareFrameState(call, BailoutId::None());
1929 break; 1934 break;
1930 } 1935 }
1931 case ObjectLiteral::Property::SETTER: { 1936 case ObjectLiteral::Property::SETTER: {
1932 Node* attr = jsgraph()->Constant(NONE); 1937 Node* attr = jsgraph()->Constant(NONE);
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after
3778 // Phi does not exist yet, introduce one. 3783 // Phi does not exist yet, introduce one.
3779 value = NewPhi(inputs, value, control); 3784 value = NewPhi(inputs, value, control);
3780 value->ReplaceInput(inputs - 1, other); 3785 value->ReplaceInput(inputs - 1, other);
3781 } 3786 }
3782 return value; 3787 return value;
3783 } 3788 }
3784 3789
3785 } // namespace compiler 3790 } // namespace compiler
3786 } // namespace internal 3791 } // namespace internal
3787 } // namespace v8 3792 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/computed-property-names-deopt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698