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

Side by Side Diff: src/parser.cc

Issue 14721009: Track computed literal properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove PLACEHOLDER_VALUE Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/objects-inl.h ('k') | src/property.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 966
967 967
968 968
969 // We will potentially reorder the property assignments, so they must be 969 // We will potentially reorder the property assignments, so they must be
970 // simple enough that the ordering does not matter. 970 // simple enough that the ordering does not matter.
971 void AssignmentFromParameter(Handle<String> name, int index) { 971 void AssignmentFromParameter(Handle<String> name, int index) {
972 EnsureInitialized(); 972 EnsureInitialized();
973 for (int i = 0; i < names_.length(); ++i) { 973 for (int i = 0; i < names_.length(); ++i) {
974 if (name->Equals(*names_[i])) { 974 if (name->Equals(*names_[i])) {
975 assigned_arguments_[i] = index; 975 assigned_arguments_[i] = index;
976 assigned_constants_[i] = isolate_->factory()->undefined_value(); 976 assigned_constants_[i] = isolate_->factory()->uninitialized_value();
977 return; 977 return;
978 } 978 }
979 } 979 }
980 names_.Add(name, zone()); 980 names_.Add(name, zone());
981 assigned_arguments_.Add(index, zone()); 981 assigned_arguments_.Add(index, zone());
982 assigned_constants_.Add(isolate_->factory()->undefined_value(), zone()); 982 assigned_constants_.Add(isolate_->factory()->uninitialized_value(), zone());
983 } 983 }
984 984
985 void AssignmentFromConstant(Handle<String> name, Handle<Object> value) { 985 void AssignmentFromConstant(Handle<String> name, Handle<Object> value) {
986 EnsureInitialized(); 986 EnsureInitialized();
987 for (int i = 0; i < names_.length(); ++i) { 987 for (int i = 0; i < names_.length(); ++i) {
988 if (name->Equals(*names_[i])) { 988 if (name->Equals(*names_[i])) {
989 assigned_arguments_[i] = -1; 989 assigned_arguments_[i] = -1;
990 assigned_constants_[i] = value; 990 assigned_constants_[i] = value;
991 return; 991 return;
992 } 992 }
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after
3779 int depth = 1; 3779 int depth = 1;
3780 bool is_holey = false; 3780 bool is_holey = false;
3781 for (int i = 0, n = values->length(); i < n; i++) { 3781 for (int i = 0, n = values->length(); i < n; i++) {
3782 MaterializedLiteral* m_literal = values->at(i)->AsMaterializedLiteral(); 3782 MaterializedLiteral* m_literal = values->at(i)->AsMaterializedLiteral();
3783 if (m_literal != NULL && m_literal->depth() + 1 > depth) { 3783 if (m_literal != NULL && m_literal->depth() + 1 > depth) {
3784 depth = m_literal->depth() + 1; 3784 depth = m_literal->depth() + 1;
3785 } 3785 }
3786 Handle<Object> boilerplate_value = GetBoilerplateValue(values->at(i)); 3786 Handle<Object> boilerplate_value = GetBoilerplateValue(values->at(i));
3787 if (boilerplate_value->IsTheHole()) { 3787 if (boilerplate_value->IsTheHole()) {
3788 is_holey = true; 3788 is_holey = true;
3789 } else if (boilerplate_value->IsUndefined()) { 3789 } else if (boilerplate_value->IsUninitialized()) {
3790 is_simple = false; 3790 is_simple = false;
3791 JSObject::SetOwnElement( 3791 JSObject::SetOwnElement(
3792 array, i, handle(Smi::FromInt(0), isolate()), kNonStrictMode); 3792 array, i, handle(Smi::FromInt(0), isolate()), kNonStrictMode);
3793 } else { 3793 } else {
3794 JSObject::SetOwnElement(array, i, boilerplate_value, kNonStrictMode); 3794 JSObject::SetOwnElement(array, i, boilerplate_value, kNonStrictMode);
3795 } 3795 }
3796 } 3796 }
3797 3797
3798 Handle<FixedArrayBase> element_values(array->elements()); 3798 Handle<FixedArrayBase> element_values(array->elements());
3799 3799
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3878 } 3878 }
3879 3879
3880 3880
3881 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { 3881 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) {
3882 if (expression->AsLiteral() != NULL) { 3882 if (expression->AsLiteral() != NULL) {
3883 return expression->AsLiteral()->handle(); 3883 return expression->AsLiteral()->handle();
3884 } 3884 }
3885 if (CompileTimeValue::IsCompileTimeValue(expression)) { 3885 if (CompileTimeValue::IsCompileTimeValue(expression)) {
3886 return CompileTimeValue::GetValue(expression); 3886 return CompileTimeValue::GetValue(expression);
3887 } 3887 }
3888 return isolate()->factory()->undefined_value(); 3888 return isolate()->factory()->uninitialized_value();
3889 } 3889 }
3890 3890
3891 // Validation per 11.1.5 Object Initialiser 3891 // Validation per 11.1.5 Object Initialiser
3892 class ObjectLiteralPropertyChecker { 3892 class ObjectLiteralPropertyChecker {
3893 public: 3893 public:
3894 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : 3894 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) :
3895 props_(Literal::Match), 3895 props_(Literal::Match),
3896 parser_(parser), 3896 parser_(parser),
3897 language_mode_(language_mode) { 3897 language_mode_(language_mode) {
3898 } 3898 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3989 if (m_literal != NULL && m_literal->depth() >= depth_acc) { 3989 if (m_literal != NULL && m_literal->depth() >= depth_acc) {
3990 depth_acc = m_literal->depth() + 1; 3990 depth_acc = m_literal->depth() + 1;
3991 } 3991 }
3992 3992
3993 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined 3993 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined
3994 // value for COMPUTED properties, the real value is filled in at 3994 // value for COMPUTED properties, the real value is filled in at
3995 // runtime. The enumeration order is maintained. 3995 // runtime. The enumeration order is maintained.
3996 Handle<Object> key = property->key()->handle(); 3996 Handle<Object> key = property->key()->handle();
3997 Handle<Object> value = GetBoilerplateValue(property->value()); 3997 Handle<Object> value = GetBoilerplateValue(property->value());
3998 3998
3999 // Ensure objects with doubles are always treated as nested objects. 3999 // Ensure objects that may, at any point in time, contain fields with double
4000 // representation are always treated as nested objects. This is true for
4001 // computed fields (value is undefined), and smi and double literals
4002 // (value->IsNumber()).
4000 // TODO(verwaest): Remove once we can store them inline. 4003 // TODO(verwaest): Remove once we can store them inline.
4001 if (FLAG_track_double_fields && value->IsNumber()) { 4004 if (FLAG_track_double_fields &&
4005 (value->IsNumber() || value->IsUninitialized())) {
4002 *may_store_doubles = true; 4006 *may_store_doubles = true;
4003 } 4007 }
4004 4008
4005 is_simple_acc = is_simple_acc && !value->IsUndefined(); 4009 is_simple_acc = is_simple_acc && !value->IsUninitialized();
4006 4010
4007 // Keep track of the number of elements in the object literal and 4011 // Keep track of the number of elements in the object literal and
4008 // the largest element index. If the largest element index is 4012 // the largest element index. If the largest element index is
4009 // much larger than the number of elements, creating an object 4013 // much larger than the number of elements, creating an object
4010 // literal with fast elements will be a waste of space. 4014 // literal with fast elements will be a waste of space.
4011 uint32_t element_index = 0; 4015 uint32_t element_index = 0;
4012 if (key->IsString() 4016 if (key->IsString()
4013 && Handle<String>::cast(key)->AsArrayIndex(&element_index) 4017 && Handle<String>::cast(key)->AsArrayIndex(&element_index)
4014 && element_index > max_element_index) { 4018 && element_index > max_element_index) {
4015 max_element_index = element_index; 4019 max_element_index = element_index;
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
6028 ASSERT(info()->isolate()->has_pending_exception()); 6032 ASSERT(info()->isolate()->has_pending_exception());
6029 } else { 6033 } else {
6030 result = ParseProgram(); 6034 result = ParseProgram();
6031 } 6035 }
6032 } 6036 }
6033 info()->SetFunction(result); 6037 info()->SetFunction(result);
6034 return (result != NULL); 6038 return (result != NULL);
6035 } 6039 }
6036 6040
6037 } } // namespace v8::internal 6041 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/property.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698