OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 4190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4201 // the hash in a separate instruction. The value hash + i + i * i is right | 4201 // the hash in a separate instruction. The value hash + i + i * i is right |
4202 // shifted in the following and instruction. | 4202 // shifted in the following and instruction. |
4203 DCHECK(NameDictionary::GetProbeOffset(i) < | 4203 DCHECK(NameDictionary::GetProbeOffset(i) < |
4204 1 << (32 - Name::kHashFieldOffset)); | 4204 1 << (32 - Name::kHashFieldOffset)); |
4205 __ addi(scratch2, scratch2, | 4205 __ addi(scratch2, scratch2, |
4206 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); | 4206 Operand(NameDictionary::GetProbeOffset(i) << Name::kHashShift)); |
4207 } | 4207 } |
4208 __ srwi(scratch2, scratch2, Operand(Name::kHashShift)); | 4208 __ srwi(scratch2, scratch2, Operand(Name::kHashShift)); |
4209 __ and_(scratch2, scratch1, scratch2); | 4209 __ and_(scratch2, scratch1, scratch2); |
4210 | 4210 |
4211 // Scale the index by multiplying by the element size. | 4211 // Scale the index by multiplying by the entry size. |
4212 STATIC_ASSERT(NameDictionary::kEntrySize == 3); | 4212 STATIC_ASSERT(NameDictionary::kEntrySize == 3); |
4213 // scratch2 = scratch2 * 3. | 4213 // scratch2 = scratch2 * 3. |
4214 __ ShiftLeftImm(ip, scratch2, Operand(1)); | 4214 __ ShiftLeftImm(ip, scratch2, Operand(1)); |
4215 __ add(scratch2, scratch2, ip); | 4215 __ add(scratch2, scratch2, ip); |
4216 | 4216 |
4217 // Check if the key is identical to the name. | 4217 // Check if the key is identical to the name. |
4218 __ ShiftLeftImm(ip, scratch2, Operand(kPointerSizeLog2)); | 4218 __ ShiftLeftImm(ip, scratch2, Operand(kPointerSizeLog2)); |
4219 __ add(scratch2, elements, ip); | 4219 __ add(scratch2, elements, ip); |
4220 __ LoadP(ip, FieldMemOperand(scratch2, kElementsStartOffset)); | 4220 __ LoadP(ip, FieldMemOperand(scratch2, kElementsStartOffset)); |
4221 __ cmp(name, ip); | 4221 __ cmp(name, ip); |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5306 Label fast_elements_case; | 5306 Label fast_elements_case; |
5307 __ cmpi(r6, Operand(FAST_ELEMENTS)); | 5307 __ cmpi(r6, Operand(FAST_ELEMENTS)); |
5308 __ beq(&fast_elements_case); | 5308 __ beq(&fast_elements_case); |
5309 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 5309 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
5310 | 5310 |
5311 __ bind(&fast_elements_case); | 5311 __ bind(&fast_elements_case); |
5312 GenerateCase(masm, FAST_ELEMENTS); | 5312 GenerateCase(masm, FAST_ELEMENTS); |
5313 } | 5313 } |
5314 | 5314 |
5315 | 5315 |
| 5316 void LoadGlobalViaContextStub::Generate(MacroAssembler* masm) { |
| 5317 Register context = cp; |
| 5318 Register result = r3; |
| 5319 Register slot = r5; |
| 5320 Register name = r6; |
| 5321 Label slow_case; |
| 5322 |
| 5323 // Go up the context chain to the script context. |
| 5324 for (int i = 0; i < depth(); ++i) { |
| 5325 __ LoadP(result, ContextOperand(context, Context::PREVIOUS_INDEX)); |
| 5326 context = result; |
| 5327 } |
| 5328 |
| 5329 // Load the PropertyCell value at the specified slot. |
| 5330 __ ShiftLeftImm(result, slot, Operand(kPointerSizeLog2)); |
| 5331 __ add(result, context, result); |
| 5332 __ LoadP(result, ContextOperand(result)); |
| 5333 __ LoadP(result, FieldMemOperand(result, PropertyCell::kValueOffset)); |
| 5334 |
| 5335 // If the result is not the_hole, return. Otherwise, handle in the runtime. |
| 5336 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
| 5337 __ Ret(ne); |
| 5338 |
| 5339 // Fallback to runtime. |
| 5340 __ bind(&slow_case); |
| 5341 __ SmiTag(slot); |
| 5342 __ Push(slot, name); |
| 5343 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 2, 1); |
| 5344 } |
| 5345 |
| 5346 |
| 5347 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { |
| 5348 Register value = r3; |
| 5349 Register slot = r5; |
| 5350 Register name = r6; |
| 5351 |
| 5352 Register cell = r4; |
| 5353 Register cell_details = r7; |
| 5354 Register cell_value = r8; |
| 5355 Register cell_value_map = r9; |
| 5356 Register scratch = r10; |
| 5357 |
| 5358 Register context = cp; |
| 5359 Register context_temp = cell; |
| 5360 |
| 5361 Label fast_heapobject_case, fast_smi_case, slow_case; |
| 5362 |
| 5363 if (FLAG_debug_code) { |
| 5364 __ CompareRoot(value, Heap::kTheHoleValueRootIndex); |
| 5365 __ Check(ne, kUnexpectedValue); |
| 5366 __ AssertName(name); |
| 5367 } |
| 5368 |
| 5369 // Go up the context chain to the script context. |
| 5370 for (int i = 0; i < depth(); i++) { |
| 5371 __ LoadP(context_temp, ContextOperand(context, Context::PREVIOUS_INDEX)); |
| 5372 context = context_temp; |
| 5373 } |
| 5374 |
| 5375 // Load the PropertyCell at the specified slot. |
| 5376 __ ShiftLeftImm(cell, slot, Operand(kPointerSizeLog2)); |
| 5377 __ add(cell, context, cell); |
| 5378 __ LoadP(cell, ContextOperand(cell)); |
| 5379 |
| 5380 // Load PropertyDetails for the cell (actually only the cell_type and kind). |
| 5381 __ LoadP(cell_details, FieldMemOperand(cell, PropertyCell::kDetailsOffset)); |
| 5382 __ SmiUntag(cell_details); |
| 5383 __ andi(cell_details, cell_details, |
| 5384 Operand(PropertyDetails::PropertyCellTypeField::kMask | |
| 5385 PropertyDetails::KindField::kMask)); |
| 5386 |
| 5387 // Check if PropertyCell holds mutable data. |
| 5388 Label not_mutable_data; |
| 5389 __ cmpi(cell_details, Operand(PropertyDetails::PropertyCellTypeField::encode( |
| 5390 PropertyCellType::kMutable) | |
| 5391 PropertyDetails::KindField::encode(kData))); |
| 5392 __ bne(¬_mutable_data); |
| 5393 __ JumpIfSmi(value, &fast_smi_case); |
| 5394 |
| 5395 __ bind(&fast_heapobject_case); |
| 5396 __ StoreP(value, FieldMemOperand(cell, PropertyCell::kValueOffset), r0); |
| 5397 // RecordWriteField clobbers the value register, so we copy it before the |
| 5398 // call. |
| 5399 __ mr(r7, value); |
| 5400 __ RecordWriteField(cell, PropertyCell::kValueOffset, r7, scratch, |
| 5401 kLRHasNotBeenSaved, kDontSaveFPRegs, EMIT_REMEMBERED_SET, |
| 5402 OMIT_SMI_CHECK); |
| 5403 __ Ret(); |
| 5404 |
| 5405 __ bind(¬_mutable_data); |
| 5406 // Check if PropertyCell value matches the new value (relevant for Constant, |
| 5407 // ConstantType and Undefined cells). |
| 5408 Label not_same_value; |
| 5409 __ LoadP(cell_value, FieldMemOperand(cell, PropertyCell::kValueOffset)); |
| 5410 __ cmp(cell_value, value); |
| 5411 __ bne(¬_same_value); |
| 5412 |
| 5413 if (FLAG_debug_code) { |
| 5414 Label done; |
| 5415 // This can only be true for Constant, ConstantType and Undefined cells, |
| 5416 // because we never store the_hole via this stub. |
| 5417 __ cmpi(cell_details, |
| 5418 Operand(PropertyDetails::PropertyCellTypeField::encode( |
| 5419 PropertyCellType::kConstant) | |
| 5420 PropertyDetails::KindField::encode(kData))); |
| 5421 __ beq(&done); |
| 5422 __ cmpi(cell_details, |
| 5423 Operand(PropertyDetails::PropertyCellTypeField::encode( |
| 5424 PropertyCellType::kConstantType) | |
| 5425 PropertyDetails::KindField::encode(kData))); |
| 5426 __ beq(&done); |
| 5427 __ cmpi(cell_details, |
| 5428 Operand(PropertyDetails::PropertyCellTypeField::encode( |
| 5429 PropertyCellType::kUndefined) | |
| 5430 PropertyDetails::KindField::encode(kData))); |
| 5431 __ Check(eq, kUnexpectedValue); |
| 5432 __ bind(&done); |
| 5433 } |
| 5434 __ Ret(); |
| 5435 __ bind(¬_same_value); |
| 5436 |
| 5437 // Check if PropertyCell contains data with constant type. |
| 5438 __ cmpi(cell_details, Operand(PropertyDetails::PropertyCellTypeField::encode( |
| 5439 PropertyCellType::kConstantType) | |
| 5440 PropertyDetails::KindField::encode(kData))); |
| 5441 __ bne(&slow_case); |
| 5442 |
| 5443 // Now either both old and new values must be smis or both must be heap |
| 5444 // objects with same map. |
| 5445 Label value_is_heap_object; |
| 5446 __ JumpIfNotSmi(value, &value_is_heap_object); |
| 5447 __ JumpIfNotSmi(cell_value, &slow_case); |
| 5448 // Old and new values are smis, no need for a write barrier here. |
| 5449 __ bind(&fast_smi_case); |
| 5450 __ StoreP(value, FieldMemOperand(cell, PropertyCell::kValueOffset), r0); |
| 5451 __ Ret(); |
| 5452 |
| 5453 __ bind(&value_is_heap_object); |
| 5454 __ JumpIfSmi(cell_value, &slow_case); |
| 5455 |
| 5456 __ LoadP(cell_value_map, FieldMemOperand(cell_value, HeapObject::kMapOffset)); |
| 5457 __ LoadP(scratch, FieldMemOperand(value, HeapObject::kMapOffset)); |
| 5458 __ cmp(cell_value_map, scratch); |
| 5459 __ beq(&fast_heapobject_case); |
| 5460 |
| 5461 // Fallback to runtime. |
| 5462 __ bind(&slow_case); |
| 5463 __ SmiTag(slot); |
| 5464 __ Push(slot, name, value); |
| 5465 __ TailCallRuntime(is_strict(language_mode()) |
| 5466 ? Runtime::kStoreGlobalViaContext_Strict |
| 5467 : Runtime::kStoreGlobalViaContext_Sloppy, |
| 5468 3, 1); |
| 5469 } |
| 5470 |
| 5471 |
5316 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 5472 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
5317 return ref0.address() - ref1.address(); | 5473 return ref0.address() - ref1.address(); |
5318 } | 5474 } |
5319 | 5475 |
5320 | 5476 |
5321 // Calls an API function. Allocates HandleScope, extracts returned value | 5477 // Calls an API function. Allocates HandleScope, extracts returned value |
5322 // from handle and propagates exceptions. Restores context. stack_space | 5478 // from handle and propagates exceptions. Restores context. stack_space |
5323 // - space to be unwound on exit (includes the call JS arguments space and | 5479 // - space to be unwound on exit (includes the call JS arguments space and |
5324 // the additional space allocated for the fast call). | 5480 // the additional space allocated for the fast call). |
5325 static void CallApiFunctionAndReturn(MacroAssembler* masm, | 5481 static void CallApiFunctionAndReturn(MacroAssembler* masm, |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5670 kStackUnwindSpace, NULL, | 5826 kStackUnwindSpace, NULL, |
5671 MemOperand(fp, 6 * kPointerSize), NULL); | 5827 MemOperand(fp, 6 * kPointerSize), NULL); |
5672 } | 5828 } |
5673 | 5829 |
5674 | 5830 |
5675 #undef __ | 5831 #undef __ |
5676 } // namespace internal | 5832 } // namespace internal |
5677 } // namespace v8 | 5833 } // namespace v8 |
5678 | 5834 |
5679 #endif // V8_TARGET_ARCH_PPC | 5835 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |