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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 | 161 |
162 info->set_prologue_offset(masm_->pc_offset()); | 162 info->set_prologue_offset(masm_->pc_offset()); |
163 __ Prologue(BUILD_FUNCTION_FRAME); | 163 __ Prologue(BUILD_FUNCTION_FRAME); |
164 info->AddNoFrameRange(0, masm_->pc_offset()); | 164 info->AddNoFrameRange(0, masm_->pc_offset()); |
165 | 165 |
166 { Comment cmnt(masm_, "[ Allocate locals"); | 166 { Comment cmnt(masm_, "[ Allocate locals"); |
167 int locals_count = info->scope()->num_stack_slots(); | 167 int locals_count = info->scope()->num_stack_slots(); |
168 // Generators allocate locals, if any, in context slots. | 168 // Generators allocate locals, if any, in context slots. |
169 ASSERT(!info->function()->is_generator() || locals_count == 0); | 169 ASSERT(!info->function()->is_generator() || locals_count == 0); |
170 if (locals_count > 0) { | 170 if (locals_count > 0) { |
171 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | 171 // Emit a loop to initialize stack cells for locals when optimizing for |
172 for (int i = 0; i < locals_count; i++) { | 172 // size. Otherwise, unroll the loop for maximum performance. |
173 if (FLAG_optimize_for_size && locals_count > 4) { | |
174 Label loop; | |
175 __ mov(r2, Operand(locals_count)); | |
176 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | |
vincent.belliard.fr
2013/10/30 08:45:02
The two LoadRoot can be factorized before the if.
Benedikt Meurer
2013/10/30 08:46:53
Hm, no, I think the mov(r2, Operand(locals_count))
vincent.belliard.fr
2013/10/30 08:53:56
We can use an other register to load undefined (fo
| |
177 __ bind(&loop); | |
178 __ sub(r2, r2, Operand(1), SetCC); | |
173 __ push(ip); | 179 __ push(ip); |
180 __ b(&loop, ne); | |
181 } else { | |
182 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); | |
183 for (int i = 0; i < locals_count; i++) { | |
184 __ push(ip); | |
185 } | |
174 } | 186 } |
175 } | 187 } |
176 } | 188 } |
177 | 189 |
178 bool function_in_register = true; | 190 bool function_in_register = true; |
179 | 191 |
180 // Possibly allocate a local context. | 192 // Possibly allocate a local context. |
181 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 193 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
182 if (heap_slots > 0) { | 194 if (heap_slots > 0) { |
183 // Argument to NewContext is the function, which is still in r1. | 195 // Argument to NewContext is the function, which is still in r1. |
(...skipping 4775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4959 ASSERT(Memory::uint32_at(interrupt_address_pointer) == | 4971 ASSERT(Memory::uint32_at(interrupt_address_pointer) == |
4960 reinterpret_cast<uint32_t>( | 4972 reinterpret_cast<uint32_t>( |
4961 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4973 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4962 return OSR_AFTER_STACK_CHECK; | 4974 return OSR_AFTER_STACK_CHECK; |
4963 } | 4975 } |
4964 | 4976 |
4965 | 4977 |
4966 } } // namespace v8::internal | 4978 } } // namespace v8::internal |
4967 | 4979 |
4968 #endif // V8_TARGET_ARCH_ARM | 4980 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |