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

Unified Diff: src/parser.cc

Issue 46088: Revert 1469 and 1472 due to a bug with array literals. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
===================================================================
--- src/parser.cc (revision 1510)
+++ src/parser.cc (working copy)
@@ -158,12 +158,10 @@
// Decide if a property should be the object boilerplate.
bool IsBoilerplateProperty(ObjectLiteral::Property* property);
- // If the expression is a literal, return the literal value;
- // if the expression is a materialized literal and is simple return a
- // compile time value as encoded by CompileTimeValue::GetValue().
- // Otherwise, return undefined literal as the placeholder
+ // If the property is CONSTANT type, it returns the literal value,
+ // otherwise, it return undefined literal as the placeholder
// in the object literal boilerplate.
- Handle<Object> GetBoilerplateValue(Expression* expression);
+ Literal* GetBoilerplateValue(ObjectLiteral::Property* property);
enum FunctionLiteralType {
EXPRESSION,
@@ -3058,7 +3056,6 @@
// Update the scope information before the pre-parsing bailout.
temp_scope_->set_contains_array_literal();
- int literal_index = temp_scope_->NextMaterializedLiteralIndex();
if (is_pre_parsing_) return NULL;
@@ -3067,19 +3064,16 @@
Factory::NewFixedArray(values.length(), TENURED);
// Fill in the literals.
- bool is_simple = true;
for (int i = 0; i < values.length(); i++) {
- Handle<Object> boilerplate_value = GetBoilerplateValue(values.at(i));
- if (boilerplate_value->IsUndefined()) {
+ Literal* literal = values.at(i)->AsLiteral();
+ if (literal == NULL) {
literals->set_the_hole(i);
- is_simple = false;
} else {
- literals->set(i, *boilerplate_value);
+ literals->set(i, *literal->handle());
}
}
- return NEW(ArrayLiteral(literals, values.elements(),
- literal_index, is_simple));
+ return NEW(ArrayLiteral(literals, values.elements()));
}
@@ -3089,51 +3083,13 @@
}
-bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
- MaterializedLiteral* lit = expression->AsMaterializedLiteral();
- return lit != NULL && lit->is_simple();
+Literal* Parser::GetBoilerplateValue(ObjectLiteral::Property* property) {
+ if (property->kind() == ObjectLiteral::Property::CONSTANT)
+ return property->value()->AsLiteral();
+ return GetLiteralUndefined();
}
-Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) {
- ASSERT(IsCompileTimeValue(expression));
- Handle<FixedArray> result = Factory::NewFixedArray(2, TENURED);
- ObjectLiteral* object_literal = expression->AsObjectLiteral();
- if (object_literal != NULL) {
- ASSERT(object_literal->is_simple());
- result->set(kTypeSlot, Smi::FromInt(OBJECT_LITERAL));
- result->set(kElementsSlot, *object_literal->constant_properties());
- } else {
- ArrayLiteral* array_literal = expression->AsArrayLiteral();
- ASSERT(array_literal != NULL && array_literal->is_simple());
- result->set(kTypeSlot, Smi::FromInt(ARRAY_LITERAL));
- result->set(kElementsSlot, *array_literal->literals());
- }
- return result;
-}
-
-CompileTimeValue::Type CompileTimeValue::GetType(Handle<FixedArray> value) {
- Smi* type_value = Smi::cast(value->get(kTypeSlot));
- return static_cast<Type>(type_value->value());
-}
-
-
-Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
- return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
-}
-
-
-Handle<Object> Parser::GetBoilerplateValue(Expression* expression) {
- if (expression->AsLiteral() != NULL) {
- return expression->AsLiteral()->handle();
- }
- if (CompileTimeValue::IsCompileTimeValue(expression)) {
- return CompileTimeValue::GetValue(expression);
- }
- return Factory::undefined_value();
-}
-
-
Expression* Parser::ParseObjectLiteral(bool* ok) {
// ObjectLiteral ::
// '{' (
@@ -3225,30 +3181,24 @@
Handle<FixedArray> constant_properties =
Factory::NewFixedArray(number_of_boilerplate_properties * 2, TENURED);
int position = 0;
- bool is_simple = true;
for (int i = 0; i < properties.length(); i++) {
ObjectLiteral::Property* property = properties.at(i);
- if (!IsBoilerplateProperty(property)) {
- is_simple = false;
- continue;
- }
+ if (!IsBoilerplateProperty(property)) continue;
// Add CONSTANT and COMPUTED properties to boilerplate. Use undefined
// value for COMPUTED properties, the real value is filled in at
// runtime. The enumeration order is maintained.
Handle<Object> key = property->key()->handle();
- Handle<Object> value = GetBoilerplateValue(property->value());
- is_simple = is_simple && !value->IsUndefined();
+ Literal* literal = GetBoilerplateValue(property);
// Add name, value pair to the fixed array.
constant_properties->set(position++, *key);
- constant_properties->set(position++, *value);
+ constant_properties->set(position++, *literal->handle());
}
return new ObjectLiteral(constant_properties,
properties.elements(),
- literal_index,
- is_simple);
+ literal_index);
}
« no previous file with comments | « src/parser.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698