OLD | NEW |
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 3716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3727 } | 3727 } |
3728 | 3728 |
3729 | 3729 |
3730 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { | 3730 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
3731 if (expression->AsLiteral() != NULL) return true; | 3731 if (expression->AsLiteral() != NULL) return true; |
3732 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); | 3732 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); |
3733 return lit != NULL && lit->is_simple(); | 3733 return lit != NULL && lit->is_simple(); |
3734 } | 3734 } |
3735 | 3735 |
3736 | 3736 |
3737 bool CompileTimeValue::ArrayLiteralElementNeedsInitialization( | |
3738 Expression* value) { | |
3739 // If value is a literal the property value is already set in the | |
3740 // boilerplate object. | |
3741 if (value->AsLiteral() != NULL) return false; | |
3742 // If value is a materialized literal the property value is already set | |
3743 // in the boilerplate object if it is simple. | |
3744 if (CompileTimeValue::IsCompileTimeValue(value)) return false; | |
3745 return true; | |
3746 } | |
3747 | |
3748 | |
3749 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { | 3737 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { |
3750 Factory* factory = Isolate::Current()->factory(); | 3738 Factory* factory = Isolate::Current()->factory(); |
3751 ASSERT(IsCompileTimeValue(expression)); | 3739 ASSERT(IsCompileTimeValue(expression)); |
3752 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); | 3740 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); |
3753 ObjectLiteral* object_literal = expression->AsObjectLiteral(); | 3741 ObjectLiteral* object_literal = expression->AsObjectLiteral(); |
3754 if (object_literal != NULL) { | 3742 if (object_literal != NULL) { |
3755 ASSERT(object_literal->is_simple()); | 3743 ASSERT(object_literal->is_simple()); |
3756 if (object_literal->fast_elements()) { | 3744 if (object_literal->fast_elements()) { |
3757 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); | 3745 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); |
3758 } else { | 3746 } else { |
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 ASSERT(info()->isolate()->has_pending_exception()); | 5925 ASSERT(info()->isolate()->has_pending_exception()); |
5938 } else { | 5926 } else { |
5939 result = ParseProgram(); | 5927 result = ParseProgram(); |
5940 } | 5928 } |
5941 } | 5929 } |
5942 info()->SetFunction(result); | 5930 info()->SetFunction(result); |
5943 return (result != NULL); | 5931 return (result != NULL); |
5944 } | 5932 } |
5945 | 5933 |
5946 } } // namespace v8::internal | 5934 } } // namespace v8::internal |
OLD | NEW |