| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 | 334 |
| 335 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { | 335 Handle<Code> FastCloneShallowArrayStub::GenerateCode() { |
| 336 return DoGenerateCode(this); | 336 return DoGenerateCode(this); |
| 337 } | 337 } |
| 338 | 338 |
| 339 | 339 |
| 340 template <> | 340 template <> |
| 341 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { | 341 HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { |
| 342 Zone* zone = this->zone(); | 342 Zone* zone = this->zone(); |
| 343 Factory* factory = isolate()->factory(); | |
| 344 HValue* undefined = graph()->GetConstantUndefined(); | 343 HValue* undefined = graph()->GetConstantUndefined(); |
| 345 | 344 |
| 346 HInstruction* boilerplate = | 345 HInstruction* boilerplate = |
| 347 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), | 346 AddInstruction(new(zone) HLoadKeyed(GetParameter(0), |
| 348 GetParameter(1), | 347 GetParameter(1), |
| 349 NULL, | 348 NULL, |
| 350 FAST_ELEMENTS)); | 349 FAST_ELEMENTS)); |
| 351 | 350 |
| 352 IfBuilder checker(this); | 351 IfBuilder checker(this); |
| 353 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); | 352 checker.IfNot<HCompareObjectEqAndBranch, HValue*>(boilerplate, undefined); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 369 flags = static_cast<HAllocate::Flags>( | 368 flags = static_cast<HAllocate::Flags>( |
| 370 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 369 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
| 371 } | 370 } |
| 372 HInstruction* object = | 371 HInstruction* object = |
| 373 AddInstruction(new(zone) HAllocate(context(), | 372 AddInstruction(new(zone) HAllocate(context(), |
| 374 size_in_bytes, | 373 size_in_bytes, |
| 375 HType::JSObject(), | 374 HType::JSObject(), |
| 376 flags)); | 375 flags)); |
| 377 | 376 |
| 378 for (int i = 0; i < size; i += kPointerSize) { | 377 for (int i = 0; i < size; i += kPointerSize) { |
| 379 HInstruction* value = | 378 HObjectAccess* access = HObjectAccess::ForInobjectOffset(zone, i); |
| 380 AddInstruction(new(zone) HLoadNamedField( | 379 HInstruction* value = AddLoad(boilerplate, access); |
| 381 boilerplate, true, Representation::Tagged(), i)); | 380 AddStore(object, access, value); |
| 382 AddInstruction(new(zone) HStoreNamedField(object, | |
| 383 factory->empty_string(), | |
| 384 value, true, | |
| 385 Representation::Tagged(), i)); | |
| 386 } | 381 } |
| 387 | 382 |
| 388 checker.ElseDeopt(); | 383 checker.ElseDeopt(); |
| 389 return object; | 384 return object; |
| 390 } | 385 } |
| 391 | 386 |
| 392 | 387 |
| 393 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { | 388 Handle<Code> FastCloneShallowObjectStub::GenerateCode() { |
| 394 return DoGenerateCode(this); | 389 return DoGenerateCode(this); |
| 395 } | 390 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { | 425 HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { |
| 431 Zone* zone = this->zone(); | 426 Zone* zone = this->zone(); |
| 432 | 427 |
| 433 HValue* js_array = GetParameter(0); | 428 HValue* js_array = GetParameter(0); |
| 434 HValue* map = GetParameter(1); | 429 HValue* map = GetParameter(1); |
| 435 | 430 |
| 436 info()->MarkAsSavesCallerDoubles(); | 431 info()->MarkAsSavesCallerDoubles(); |
| 437 | 432 |
| 438 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); | 433 AddInstruction(new(zone) HTrapAllocationMemento(js_array)); |
| 439 | 434 |
| 440 HInstruction* array_length = | 435 HInstruction* array_length = AddLoad(js_array, |
| 441 AddInstruction(HLoadNamedField::NewArrayLength( | 436 HObjectAccess::ForArrayLength()); |
| 442 zone, js_array, js_array, HType::Smi())); | 437 array_length->set_type(HType::Smi()); |
| 443 | 438 |
| 444 ElementsKind to_kind = casted_stub()->to_kind(); | 439 ElementsKind to_kind = casted_stub()->to_kind(); |
| 445 BuildNewSpaceArrayCheck(array_length, to_kind); | 440 BuildNewSpaceArrayCheck(array_length, to_kind); |
| 446 | 441 |
| 447 IfBuilder if_builder(this); | 442 IfBuilder if_builder(this); |
| 448 | 443 |
| 449 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); | 444 if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ); |
| 450 if_builder.Then(); | 445 if_builder.Then(); |
| 451 | 446 |
| 452 // Nothing to do, just change the map. | 447 // Nothing to do, just change the map. |
| 453 | 448 |
| 454 if_builder.Else(); | 449 if_builder.Else(); |
| 455 | 450 |
| 456 HInstruction* elements = | 451 HInstruction* elements = |
| 457 AddInstruction(new(zone) HLoadElements(js_array, js_array)); | 452 AddInstruction(new(zone) HLoadElements(js_array, js_array)); |
| 458 | 453 |
| 459 HInstruction* elements_length = | 454 HInstruction* elements_length = |
| 460 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 455 AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
| 461 | 456 |
| 462 HValue* new_elements = | 457 HValue* new_elements = |
| 463 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); | 458 BuildAllocateAndInitializeElements(context(), to_kind, elements_length); |
| 464 | 459 |
| 465 BuildCopyElements(context(), elements, | 460 BuildCopyElements(context(), elements, |
| 466 casted_stub()->from_kind(), new_elements, | 461 casted_stub()->from_kind(), new_elements, |
| 467 to_kind, array_length, elements_length); | 462 to_kind, array_length, elements_length); |
| 468 | 463 |
| 469 Factory* factory = isolate()->factory(); | 464 AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements); |
| 470 | |
| 471 AddInstruction(new(zone) HStoreNamedField(js_array, | |
| 472 factory->elements_field_string(), | |
| 473 new_elements, true, | |
| 474 Representation::Tagged(), | |
| 475 JSArray::kElementsOffset)); | |
| 476 | 465 |
| 477 if_builder.End(); | 466 if_builder.End(); |
| 478 | 467 |
| 479 AddInstruction(new(zone) HStoreNamedField(js_array, factory->length_string(), | 468 AddStore(js_array, HObjectAccess::ForMap(), map); |
| 480 map, true, | 469 |
| 481 Representation::Tagged(), | |
| 482 JSArray::kMapOffset)); | |
| 483 return js_array; | 470 return js_array; |
| 484 } | 471 } |
| 485 | 472 |
| 486 | 473 |
| 487 Handle<Code> TransitionElementsKindStub::GenerateCode() { | 474 Handle<Code> TransitionElementsKindStub::GenerateCode() { |
| 488 return DoGenerateCode(this); | 475 return DoGenerateCode(this); |
| 489 } | 476 } |
| 490 | 477 |
| 491 | 478 |
| 492 template <> | 479 template <> |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 ? graph()->GetConstantSmi1() | 621 ? graph()->GetConstantSmi1() |
| 635 : graph()->GetConstantUndefined(); | 622 : graph()->GetConstantUndefined(); |
| 636 } | 623 } |
| 637 | 624 |
| 638 | 625 |
| 639 Handle<Code> CompareNilICStub::GenerateCode() { | 626 Handle<Code> CompareNilICStub::GenerateCode() { |
| 640 return DoGenerateCode(this); | 627 return DoGenerateCode(this); |
| 641 } | 628 } |
| 642 | 629 |
| 643 } } // namespace v8::internal | 630 } } // namespace v8::internal |
| OLD | NEW |