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 3910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3921 literal = new(zone()) HFastLiteral(context, | 3921 literal = new(zone()) HFastLiteral(context, |
3922 boilerplate, | 3922 boilerplate, |
3923 total_size, | 3923 total_size, |
3924 expr->literal_index(), | 3924 expr->literal_index(), |
3925 expr->depth()); | 3925 expr->depth()); |
3926 } else { | 3926 } else { |
3927 literal = new(zone()) HArrayLiteral(context, | 3927 literal = new(zone()) HArrayLiteral(context, |
3928 boilerplate, | 3928 boilerplate, |
3929 length, | 3929 length, |
3930 expr->literal_index(), | 3930 expr->literal_index(), |
3931 expr->depth()); | 3931 expr->depth(), |
| 3932 expr->constant_elements()); |
3932 } | 3933 } |
3933 | 3934 |
3934 // The array is expected in the bailout environment during computation | 3935 // The array is expected in the bailout environment during computation |
3935 // of the property values and is the value of the entire expression. | 3936 // of the property values and is the value of the entire expression. |
3936 PushAndAdd(literal); | 3937 PushAndAdd(literal); |
3937 | 3938 |
3938 HLoadElements* elements = NULL; | 3939 HLoadElements* elements = NULL; |
3939 | 3940 |
3940 for (int i = 0; i < length; i++) { | 3941 for (int i = 0; i < length; i++) { |
3941 Expression* subexpr = subexprs->at(i); | 3942 Expression* subexpr = subexprs->at(i); |
(...skipping 3204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7146 ASSERT(current_block() != NULL); | 7147 ASSERT(current_block() != NULL); |
7147 ASSERT(current_block()->HasPredecessor()); | 7148 ASSERT(current_block()->HasPredecessor()); |
7148 EqualityKind kind = | 7149 EqualityKind kind = |
7149 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality; | 7150 expr->op() == Token::EQ_STRICT ? kStrictEquality : kNonStrictEquality; |
7150 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil); | 7151 HIsNilAndBranch* instr = new(zone()) HIsNilAndBranch(value, kind, nil); |
7151 instr->set_position(expr->position()); | 7152 instr->set_position(expr->position()); |
7152 return ast_context()->ReturnControl(instr, expr->id()); | 7153 return ast_context()->ReturnControl(instr, expr->id()); |
7153 } | 7154 } |
7154 | 7155 |
7155 | 7156 |
| 7157 HInstruction* HGraphBuilder::BuildThisFunction() { |
| 7158 // If we share optimized code between different closures, the |
| 7159 // this-function is not a constant, except inside an inlined body. |
| 7160 if (function_state()->outer() != NULL) { |
| 7161 return new(zone()) HConstant( |
| 7162 function_state()->compilation_info()->closure(), |
| 7163 Representation::Tagged()); |
| 7164 } else { |
| 7165 return new(zone()) HThisFunction; |
| 7166 } |
| 7167 } |
| 7168 |
| 7169 |
7156 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 7170 void HGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
7157 ASSERT(!HasStackOverflow()); | 7171 ASSERT(!HasStackOverflow()); |
7158 ASSERT(current_block() != NULL); | 7172 ASSERT(current_block() != NULL); |
7159 ASSERT(current_block()->HasPredecessor()); | 7173 ASSERT(current_block()->HasPredecessor()); |
7160 HThisFunction* self = new(zone()) HThisFunction( | 7174 HInstruction* instr = BuildThisFunction(); |
7161 function_state()->compilation_info()->closure()); | 7175 return ast_context()->ReturnInstruction(instr, expr->id()); |
7162 return ast_context()->ReturnInstruction(self, expr->id()); | |
7163 } | 7176 } |
7164 | 7177 |
7165 | 7178 |
7166 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { | 7179 void HGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
7167 ASSERT(globals_.is_empty()); | 7180 ASSERT(globals_.is_empty()); |
7168 AstVisitor::VisitDeclarations(declarations); | 7181 AstVisitor::VisitDeclarations(declarations); |
7169 if (!globals_.is_empty()) { | 7182 if (!globals_.is_empty()) { |
7170 Handle<FixedArray> array = | 7183 Handle<FixedArray> array = |
7171 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); | 7184 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); |
7172 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); | 7185 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); |
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8368 } | 8381 } |
8369 } | 8382 } |
8370 | 8383 |
8371 #ifdef DEBUG | 8384 #ifdef DEBUG |
8372 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8385 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
8373 if (allocator_ != NULL) allocator_->Verify(); | 8386 if (allocator_ != NULL) allocator_->Verify(); |
8374 #endif | 8387 #endif |
8375 } | 8388 } |
8376 | 8389 |
8377 } } // namespace v8::internal | 8390 } } // namespace v8::internal |
OLD | NEW |