| 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 4903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4914 } | 4914 } |
| 4915 } | 4915 } |
| 4916 } else { | 4916 } else { |
| 4917 UNREACHABLE(); | 4917 UNREACHABLE(); |
| 4918 } | 4918 } |
| 4919 } | 4919 } |
| 4920 } | 4920 } |
| 4921 | 4921 |
| 4922 | 4922 |
| 4923 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { | 4923 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
| 4924 int size = instr->hydrogen()->total_size(); | 4924 Handle<JSObject> result = instr->hydrogen()->boilerplate(); |
| 4925 ElementsKind boilerplate_elements_kind = | |
| 4926 instr->hydrogen()->boilerplate()->GetElementsKind(); | |
| 4927 | 4925 |
| 4928 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4926 if (instr->hydrogen()->TransitionRequested()) { |
| 4929 // than the expected one. The check isn't necessary if the boilerplate has | 4927 ElementsKind to_kind = instr->hydrogen()->TransitionTo(); |
| 4930 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 4928 result = Runtime::DeepCopyBoilerplate(isolate(), |
| 4931 if (CanTransitionToMoreGeneralFastElementsKind( | 4929 instr->hydrogen()->boilerplate()); |
| 4932 boilerplate_elements_kind, true)) { | 4930 CHECK(!result.is_null()); |
| 4933 __ LoadHeapObject(rbx, instr->hydrogen()->boilerplate()); | 4931 // Now transition the copy |
| 4934 __ movq(rcx, FieldOperand(rbx, HeapObject::kMapOffset)); | 4932 CHECK(!JSObject::TransitionElementsKind(result, to_kind).is_null()); |
| 4935 // Load the map's "bit field 2". | 4933 } else { |
| 4936 __ movb(rcx, FieldOperand(rcx, Map::kBitField2Offset)); | 4934 ElementsKind boilerplate_elements_kind = result->GetElementsKind(); |
| 4937 // Retrieve elements_kind from bit field 2. | 4935 |
| 4938 __ and_(rcx, Immediate(Map::kElementsKindMask)); | 4936 // Deopt if the array literal boilerplate ElementsKind is of a type |
| 4939 __ cmpb(rcx, Immediate(boilerplate_elements_kind << | 4937 // different than the expected one. The check isn't necessary if the |
| 4940 Map::kElementsKindShift)); | 4938 // boilerplate has already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
| 4941 DeoptimizeIf(not_equal, instr->environment()); | 4939 if (CanTransitionToMoreGeneralFastElementsKind( |
| 4940 boilerplate_elements_kind, true)) { |
| 4941 __ LoadHeapObject(rbx, result); |
| 4942 __ movq(rcx, FieldOperand(rbx, HeapObject::kMapOffset)); |
| 4943 // Load the map's "bit field 2". |
| 4944 __ movb(rcx, FieldOperand(rcx, Map::kBitField2Offset)); |
| 4945 // Retrieve elements_kind from bit field 2. |
| 4946 __ and_(rcx, Immediate(Map::kElementsKindMask)); |
| 4947 __ cmpb(rcx, Immediate(boilerplate_elements_kind << |
| 4948 Map::kElementsKindShift)); |
| 4949 DeoptimizeIf(not_equal, instr->environment()); |
| 4950 } |
| 4942 } | 4951 } |
| 4943 | 4952 |
| 4953 // We need to compute the size now. |
| 4954 int size = 0; |
| 4955 int max_properties = HFastLiteral::kMaxLiteralProperties; |
| 4956 HFastLiteral::IsFastLiteral(result, |
| 4957 HFastLiteral::kMaxLiteralDepth, |
| 4958 &max_properties, |
| 4959 &size); |
| 4960 |
| 4944 // Allocate all objects that are part of the literal in one big | 4961 // Allocate all objects that are part of the literal in one big |
| 4945 // allocation. This avoids multiple limit checks. | 4962 // allocation. This avoids multiple limit checks. |
| 4946 Label allocated, runtime_allocate; | 4963 Label allocated, runtime_allocate; |
| 4947 __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT); | 4964 __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT); |
| 4948 __ jmp(&allocated); | 4965 __ jmp(&allocated); |
| 4949 | 4966 |
| 4950 __ bind(&runtime_allocate); | 4967 __ bind(&runtime_allocate); |
| 4951 __ Push(Smi::FromInt(size)); | 4968 __ Push(Smi::FromInt(size)); |
| 4952 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | 4969 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); |
| 4953 | 4970 |
| 4954 __ bind(&allocated); | 4971 __ bind(&allocated); |
| 4955 int offset = 0; | 4972 int offset = 0; |
| 4956 __ LoadHeapObject(rbx, instr->hydrogen()->boilerplate()); | 4973 __ LoadHeapObject(rbx, result); |
| 4957 EmitDeepCopy(instr->hydrogen()->boilerplate(), rax, rbx, &offset); | 4974 EmitDeepCopy(result, rax, rbx, &offset); |
| 4958 ASSERT_EQ(size, offset); | 4975 ASSERT_EQ(size, offset); |
| 4959 } | 4976 } |
| 4960 | 4977 |
| 4961 | 4978 |
| 4962 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 4979 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { |
| 4963 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 4980 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
| 4964 Handle<FixedArray> constant_properties = | 4981 Handle<FixedArray> constant_properties = |
| 4965 instr->hydrogen()->constant_properties(); | 4982 instr->hydrogen()->constant_properties(); |
| 4966 | 4983 |
| 4967 // Set up the parameters to the stub/runtime call. | 4984 // Set up the parameters to the stub/runtime call. |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5424 FixedArray::kHeaderSize - kPointerSize)); | 5441 FixedArray::kHeaderSize - kPointerSize)); |
| 5425 __ bind(&done); | 5442 __ bind(&done); |
| 5426 } | 5443 } |
| 5427 | 5444 |
| 5428 | 5445 |
| 5429 #undef __ | 5446 #undef __ |
| 5430 | 5447 |
| 5431 } } // namespace v8::internal | 5448 } } // namespace v8::internal |
| 5432 | 5449 |
| 5433 #endif // V8_TARGET_ARCH_X64 | 5450 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |