OLD | NEW |
1 | 1 |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 // Load current lexical context from the stack frame. | 428 // Load current lexical context from the stack frame. |
429 lw(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 429 lw(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
430 // In debug mode, make sure the lexical context is set. | 430 // In debug mode, make sure the lexical context is set. |
431 #ifdef DEBUG | 431 #ifdef DEBUG |
432 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext, | 432 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext, |
433 scratch, Operand(zero_reg)); | 433 scratch, Operand(zero_reg)); |
434 #endif | 434 #endif |
435 | 435 |
436 // Load the native context of the current context. | 436 // Load the native context of the current context. |
437 int offset = | 437 lw(scratch, ContextMemOperand(scratch, Context::NATIVE_CONTEXT_INDEX)); |
438 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; | |
439 lw(scratch, FieldMemOperand(scratch, offset)); | |
440 lw(scratch, FieldMemOperand(scratch, JSGlobalObject::kNativeContextOffset)); | |
441 | 438 |
442 // Check the context is a native context. | 439 // Check the context is a native context. |
443 if (emit_debug_code()) { | 440 if (emit_debug_code()) { |
444 push(holder_reg); // Temporarily save holder on the stack. | 441 push(holder_reg); // Temporarily save holder on the stack. |
445 // Read the first word and compare to the native_context_map. | 442 // Read the first word and compare to the native_context_map. |
446 lw(holder_reg, FieldMemOperand(scratch, HeapObject::kMapOffset)); | 443 lw(holder_reg, FieldMemOperand(scratch, HeapObject::kMapOffset)); |
447 LoadRoot(at, Heap::kNativeContextMapRootIndex); | 444 LoadRoot(at, Heap::kNativeContextMapRootIndex); |
448 Check(eq, kJSGlobalObjectNativeContextShouldBeANativeContext, | 445 Check(eq, kJSGlobalObjectNativeContextShouldBeANativeContext, |
449 holder_reg, Operand(at)); | 446 holder_reg, Operand(at)); |
450 pop(holder_reg); // Restore holder. | 447 pop(holder_reg); // Restore holder. |
(...skipping 4058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4509 Operand(zero_reg), | 4506 Operand(zero_reg), |
4510 bd); | 4507 bd); |
4511 } | 4508 } |
4512 | 4509 |
4513 | 4510 |
4514 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, | 4511 void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag, |
4515 const CallWrapper& call_wrapper) { | 4512 const CallWrapper& call_wrapper) { |
4516 // You can't call a builtin without a valid frame. | 4513 // You can't call a builtin without a valid frame. |
4517 DCHECK(flag == JUMP_FUNCTION || has_frame()); | 4514 DCHECK(flag == JUMP_FUNCTION || has_frame()); |
4518 | 4515 |
4519 GetBuiltinEntry(t9, native_context_index); | 4516 LoadNativeContextSlot(native_context_index, a1); |
| 4517 lw(t9, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
4520 if (flag == CALL_FUNCTION) { | 4518 if (flag == CALL_FUNCTION) { |
4521 call_wrapper.BeforeCall(CallSize(t9)); | 4519 call_wrapper.BeforeCall(CallSize(t9)); |
4522 Call(t9); | 4520 Call(t9); |
4523 call_wrapper.AfterCall(); | 4521 call_wrapper.AfterCall(); |
4524 } else { | 4522 } else { |
4525 DCHECK(flag == JUMP_FUNCTION); | 4523 DCHECK(flag == JUMP_FUNCTION); |
4526 Jump(t9); | 4524 Jump(t9); |
4527 } | 4525 } |
4528 } | 4526 } |
4529 | 4527 |
4530 | 4528 |
4531 void MacroAssembler::GetBuiltinFunction(Register target, | |
4532 int native_context_index) { | |
4533 // Load the builtins object into target register. | |
4534 lw(target, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
4535 lw(target, FieldMemOperand(target, JSGlobalObject::kNativeContextOffset)); | |
4536 // Load the JavaScript builtin function from the builtins object. | |
4537 lw(target, ContextOperand(target, native_context_index)); | |
4538 } | |
4539 | |
4540 | |
4541 void MacroAssembler::GetBuiltinEntry(Register target, | |
4542 int native_context_index) { | |
4543 DCHECK(!target.is(a1)); | |
4544 GetBuiltinFunction(a1, native_context_index); | |
4545 // Load the code entry point from the builtins object. | |
4546 lw(target, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | |
4547 } | |
4548 | |
4549 | |
4550 void MacroAssembler::SetCounter(StatsCounter* counter, int value, | 4529 void MacroAssembler::SetCounter(StatsCounter* counter, int value, |
4551 Register scratch1, Register scratch2) { | 4530 Register scratch1, Register scratch2) { |
4552 if (FLAG_native_code_counters && counter->Enabled()) { | 4531 if (FLAG_native_code_counters && counter->Enabled()) { |
4553 li(scratch1, Operand(value)); | 4532 li(scratch1, Operand(value)); |
4554 li(scratch2, Operand(ExternalReference(counter))); | 4533 li(scratch2, Operand(ExternalReference(counter))); |
4555 sw(scratch1, MemOperand(scratch2)); | 4534 sw(scratch1, MemOperand(scratch2)); |
4556 } | 4535 } |
4557 } | 4536 } |
4558 | 4537 |
4559 | 4538 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4673 } | 4652 } |
4674 } else { | 4653 } else { |
4675 // Slot is in the current function context. Move it into the | 4654 // Slot is in the current function context. Move it into the |
4676 // destination register in case we store into it (the write barrier | 4655 // destination register in case we store into it (the write barrier |
4677 // cannot be allowed to destroy the context in esi). | 4656 // cannot be allowed to destroy the context in esi). |
4678 Move(dst, cp); | 4657 Move(dst, cp); |
4679 } | 4658 } |
4680 } | 4659 } |
4681 | 4660 |
4682 | 4661 |
4683 void MacroAssembler::LoadGlobalProxy(Register dst) { | |
4684 lw(dst, GlobalObjectOperand()); | |
4685 lw(dst, FieldMemOperand(dst, JSGlobalObject::kGlobalProxyOffset)); | |
4686 } | |
4687 | |
4688 | |
4689 void MacroAssembler::LoadTransitionedArrayMapConditional( | 4662 void MacroAssembler::LoadTransitionedArrayMapConditional( |
4690 ElementsKind expected_kind, | 4663 ElementsKind expected_kind, |
4691 ElementsKind transitioned_kind, | 4664 ElementsKind transitioned_kind, |
4692 Register map_in_out, | 4665 Register map_in_out, |
4693 Register scratch, | 4666 Register scratch, |
4694 Label* no_map_match) { | 4667 Label* no_map_match) { |
4695 // Load the global or builtins object from the current context. | |
4696 lw(scratch, | |
4697 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
4698 lw(scratch, FieldMemOperand(scratch, JSGlobalObject::kNativeContextOffset)); | |
4699 | |
4700 // Check that the function's map is the same as the expected cached map. | 4668 // Check that the function's map is the same as the expected cached map. |
4701 lw(scratch, | 4669 LoadNativeContextSlot(Context::JS_ARRAY_MAPS_INDEX, scratch); |
4702 MemOperand(scratch, | |
4703 Context::SlotOffset(Context::JS_ARRAY_MAPS_INDEX))); | |
4704 size_t offset = expected_kind * kPointerSize + | 4670 size_t offset = expected_kind * kPointerSize + |
4705 FixedArrayBase::kHeaderSize; | 4671 FixedArrayBase::kHeaderSize; |
4706 lw(at, FieldMemOperand(scratch, offset)); | 4672 lw(at, FieldMemOperand(scratch, offset)); |
4707 Branch(no_map_match, ne, map_in_out, Operand(at)); | 4673 Branch(no_map_match, ne, map_in_out, Operand(at)); |
4708 | 4674 |
4709 // Use the transitioned cached map. | 4675 // Use the transitioned cached map. |
4710 offset = transitioned_kind * kPointerSize + | 4676 offset = transitioned_kind * kPointerSize + |
4711 FixedArrayBase::kHeaderSize; | 4677 FixedArrayBase::kHeaderSize; |
4712 lw(map_in_out, FieldMemOperand(scratch, offset)); | 4678 lw(map_in_out, FieldMemOperand(scratch, offset)); |
4713 } | 4679 } |
4714 | 4680 |
4715 | 4681 |
4716 void MacroAssembler::LoadGlobalFunction(int index, Register function) { | 4682 void MacroAssembler::LoadNativeContextSlot(int index, Register dst) { |
4717 // Load the global or builtins object from the current context. | 4683 lw(dst, NativeContextMemOperand()); |
4718 lw(function, | 4684 lw(dst, ContextMemOperand(dst, index)); |
4719 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
4720 // Load the native context from the global or builtins object. | |
4721 lw(function, FieldMemOperand(function, JSGlobalObject::kNativeContextOffset)); | |
4722 // Load the function from the native context. | |
4723 lw(function, MemOperand(function, Context::SlotOffset(index))); | |
4724 } | 4685 } |
4725 | 4686 |
4726 | 4687 |
4727 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, | 4688 void MacroAssembler::LoadGlobalFunctionInitialMap(Register function, |
4728 Register map, | 4689 Register map, |
4729 Register scratch) { | 4690 Register scratch) { |
4730 // Load the initial map. The global functions all have initial maps. | 4691 // Load the initial map. The global functions all have initial maps. |
4731 lw(map, FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); | 4692 lw(map, FieldMemOperand(function, JSFunction::kPrototypeOrInitialMapOffset)); |
4732 if (emit_debug_code()) { | 4693 if (emit_debug_code()) { |
4733 Label ok, fail; | 4694 Label ok, fail; |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5864 if (mag.shift > 0) sra(result, result, mag.shift); | 5825 if (mag.shift > 0) sra(result, result, mag.shift); |
5865 srl(at, dividend, 31); | 5826 srl(at, dividend, 31); |
5866 Addu(result, result, Operand(at)); | 5827 Addu(result, result, Operand(at)); |
5867 } | 5828 } |
5868 | 5829 |
5869 | 5830 |
5870 } // namespace internal | 5831 } // namespace internal |
5871 } // namespace v8 | 5832 } // namespace v8 |
5872 | 5833 |
5873 #endif // V8_TARGET_ARCH_MIPS | 5834 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |