OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 3319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 for (int i = 0; i < length; i++) { | 3330 for (int i = 0; i < length; i++) { |
3331 Expression* subexpr = subexprs->at(i); | 3331 Expression* subexpr = subexprs->at(i); |
3332 // If the subexpression is a literal or a simple materialized literal it | 3332 // If the subexpression is a literal or a simple materialized literal it |
3333 // is already set in the cloned array. | 3333 // is already set in the cloned array. |
3334 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 3334 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
3335 | 3335 |
3336 CHECK_ALIVE(VisitForValue(subexpr)); | 3336 CHECK_ALIVE(VisitForValue(subexpr)); |
3337 HValue* value = Pop(); | 3337 HValue* value = Pop(); |
3338 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal"); | 3338 if (!Smi::IsValid(i)) return Bailout("Non-smi key in array literal"); |
3339 | 3339 |
3340 // Load the elements array before the first store. | 3340 elements = new(zone()) HLoadElements(literal); |
3341 if (elements == NULL) { | 3341 AddInstruction(elements); |
3342 elements = new(zone()) HLoadElements(literal); | |
3343 AddInstruction(elements); | |
3344 } | |
3345 | 3342 |
3346 HValue* key = AddInstruction( | 3343 HValue* key = AddInstruction( |
3347 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i)), | 3344 new(zone()) HConstant(Handle<Object>(Smi::FromInt(i)), |
3348 Representation::Integer32())); | 3345 Representation::Integer32())); |
3349 HInstruction* elements_kind = | 3346 HInstruction* elements_kind = |
3350 AddInstruction(new(zone()) HElementsKind(literal)); | 3347 AddInstruction(new(zone()) HElementsKind(literal)); |
3351 HBasicBlock* store_fast = graph()->CreateBasicBlock(); | 3348 HBasicBlock* store_fast = graph()->CreateBasicBlock(); |
3352 // Two empty blocks to satisfy edge split form. | 3349 // Two empty blocks to satisfy edge split form. |
3353 HBasicBlock* store_fast_edgesplit1 = graph()->CreateBasicBlock(); | 3350 HBasicBlock* store_fast_edgesplit1 = graph()->CreateBasicBlock(); |
3354 HBasicBlock* store_fast_edgesplit2 = graph()->CreateBasicBlock(); | 3351 HBasicBlock* store_fast_edgesplit2 = graph()->CreateBasicBlock(); |
3355 HBasicBlock* store_generic = graph()->CreateBasicBlock(); | 3352 HBasicBlock* store_generic = graph()->CreateBasicBlock(); |
3356 HBasicBlock* check_smi_only_elements = graph()->CreateBasicBlock(); | 3353 HBasicBlock* check_smi_only_elements = graph()->CreateBasicBlock(); |
3357 HBasicBlock* join = graph()->CreateBasicBlock(); | 3354 HBasicBlock* join = graph()->CreateBasicBlock(); |
3358 | 3355 |
3359 HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(value); | 3356 HIsSmiAndBranch* smicheck = new(zone()) HIsSmiAndBranch(value); |
3360 smicheck->SetSuccessorAt(0, store_fast_edgesplit1); | 3357 smicheck->SetSuccessorAt(0, store_fast_edgesplit1); |
3361 smicheck->SetSuccessorAt(1, check_smi_only_elements); | 3358 smicheck->SetSuccessorAt(1, check_smi_only_elements); |
3362 current_block()->Finish(smicheck); | 3359 current_block()->Finish(smicheck); |
3363 store_fast_edgesplit1->Finish(new(zone()) HGoto(store_fast)); | 3360 store_fast_edgesplit1->Finish(new(zone()) HGoto(store_fast)); |
3364 | 3361 |
3365 set_current_block(check_smi_only_elements); | 3362 set_current_block(check_smi_only_elements); |
3366 HCompareConstantEqAndBranch* smi_elements_check = | 3363 HCompareConstantEqAndBranch* smi_elements_check = |
3367 new(zone()) HCompareConstantEqAndBranch(elements_kind, | 3364 new(zone()) HCompareConstantEqAndBranch(elements_kind, |
3368 FAST_SMI_ONLY_ELEMENTS, | 3365 FAST_ELEMENTS, |
3369 Token::EQ_STRICT); | 3366 Token::EQ_STRICT); |
3370 smi_elements_check->SetSuccessorAt(0, store_generic); | 3367 smi_elements_check->SetSuccessorAt(0, store_fast_edgesplit2); |
3371 smi_elements_check->SetSuccessorAt(1, store_fast_edgesplit2); | 3368 smi_elements_check->SetSuccessorAt(1, store_generic); |
3372 current_block()->Finish(smi_elements_check); | 3369 current_block()->Finish(smi_elements_check); |
3373 store_fast_edgesplit2->Finish(new(zone()) HGoto(store_fast)); | 3370 store_fast_edgesplit2->Finish(new(zone()) HGoto(store_fast)); |
3374 | 3371 |
3375 set_current_block(store_fast); | 3372 set_current_block(store_fast); |
3376 AddInstruction(new(zone()) HStoreKeyedFastElement(elements, key, value)); | 3373 AddInstruction(new(zone()) HStoreKeyedFastElement(elements, key, value)); |
3377 store_fast->Goto(join); | 3374 store_fast->Goto(join); |
3378 | 3375 |
3379 set_current_block(store_generic); | 3376 set_current_block(store_generic); |
3380 AddInstruction(BuildStoreKeyedGeneric(literal, key, value)); | 3377 AddInstruction(BuildStoreKeyedGeneric(literal, key, value)); |
3381 store_generic->Goto(join); | 3378 store_generic->Goto(join); |
(...skipping 3555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6937 } | 6934 } |
6938 } | 6935 } |
6939 | 6936 |
6940 #ifdef DEBUG | 6937 #ifdef DEBUG |
6941 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6938 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
6942 if (allocator_ != NULL) allocator_->Verify(); | 6939 if (allocator_ != NULL) allocator_->Verify(); |
6943 #endif | 6940 #endif |
6944 } | 6941 } |
6945 | 6942 |
6946 } } // namespace v8::internal | 6943 } } // namespace v8::internal |
OLD | NEW |