| 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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 __ li(a1, Operand(constant_properties)); | 1646 __ li(a1, Operand(constant_properties)); |
| 1647 int flags = expr->fast_elements() | 1647 int flags = expr->fast_elements() |
| 1648 ? ObjectLiteral::kFastElements | 1648 ? ObjectLiteral::kFastElements |
| 1649 : ObjectLiteral::kNoFlags; | 1649 : ObjectLiteral::kNoFlags; |
| 1650 flags |= expr->has_function() | 1650 flags |= expr->has_function() |
| 1651 ? ObjectLiteral::kHasFunction | 1651 ? ObjectLiteral::kHasFunction |
| 1652 : ObjectLiteral::kNoFlags; | 1652 : ObjectLiteral::kNoFlags; |
| 1653 __ li(a0, Operand(Smi::FromInt(flags))); | 1653 __ li(a0, Operand(Smi::FromInt(flags))); |
| 1654 int properties_count = constant_properties->length() / 2; | 1654 int properties_count = constant_properties->length() / 2; |
| 1655 if ((FLAG_track_double_fields && expr->may_store_doubles()) || | 1655 if ((FLAG_track_double_fields && expr->may_store_doubles()) || |
| 1656 expr->depth() > 1) { | 1656 expr->depth() > 1 || Serializer::enabled() || |
| 1657 flags != ObjectLiteral::kFastElements || |
| 1658 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 1657 __ Push(a3, a2, a1, a0); | 1659 __ Push(a3, a2, a1, a0); |
| 1658 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1660 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1659 } else if (Serializer::enabled() || flags != ObjectLiteral::kFastElements || | |
| 1660 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | |
| 1661 __ Push(a3, a2, a1, a0); | |
| 1662 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); | |
| 1663 } else { | 1661 } else { |
| 1664 FastCloneShallowObjectStub stub(properties_count); | 1662 FastCloneShallowObjectStub stub(properties_count); |
| 1665 __ CallStub(&stub); | 1663 __ CallStub(&stub); |
| 1666 } | 1664 } |
| 1667 | 1665 |
| 1668 // If result_saved is true the result is on top of the stack. If | 1666 // If result_saved is true the result is on top of the stack. If |
| 1669 // result_saved is false the result is in v0. | 1667 // result_saved is false the result is in v0. |
| 1670 bool result_saved = false; | 1668 bool result_saved = false; |
| 1671 | 1669 |
| 1672 // Mark all computed expressions that are bound to a key that | 1670 // Mark all computed expressions that are bound to a key that |
| (...skipping 3246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4919 __ Call(finally_entry_); | 4917 __ Call(finally_entry_); |
| 4920 | 4918 |
| 4921 *stack_depth = 0; | 4919 *stack_depth = 0; |
| 4922 *context_length = 0; | 4920 *context_length = 0; |
| 4923 return previous_; | 4921 return previous_; |
| 4924 } | 4922 } |
| 4925 | 4923 |
| 4926 | 4924 |
| 4927 #undef __ | 4925 #undef __ |
| 4928 | 4926 |
| 4927 |
| 4928 // This structure comes from FullCodeGenerator::EmitBackEdgeBookkeeping. |
| 4929 // The back edge bookkeeping code matches the pattern: |
| 4930 // |
| 4931 // sltu at, sp, t0 / slt at, a3, zero_reg (in case of count based interrupts) |
| 4932 // beq at, zero_reg, ok |
| 4933 // lui t9, <interrupt stub address> upper |
| 4934 // ori t9, <interrupt stub address> lower |
| 4935 // jalr t9 |
| 4936 // nop |
| 4937 // ok-label ----- pc_after points here |
| 4938 // |
| 4939 // We patch the code to the following form: |
| 4940 // |
| 4941 // addiu at, zero_reg, 1 |
| 4942 // beq at, zero_reg, ok ;; Not changed |
| 4943 // lui t9, <on-stack replacement address> upper |
| 4944 // ori t9, <on-stack replacement address> lower |
| 4945 // jalr t9 ;; Not changed |
| 4946 // nop ;; Not changed |
| 4947 // ok-label ----- pc_after points here |
| 4948 |
| 4949 void BackEdgeTable::PatchAt(Code* unoptimized_code, |
| 4950 Address pc_after, |
| 4951 Code* replacement_code) { |
| 4952 static const int kInstrSize = Assembler::kInstrSize; |
| 4953 // Replace the sltu instruction with load-imm 1 to at, so beq is not taken. |
| 4954 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); |
| 4955 patcher.masm()->addiu(at, zero_reg, 1); |
| 4956 // Replace the stack check address in the load-immediate (lui/ori pair) |
| 4957 // with the entry address of the replacement code. |
| 4958 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, |
| 4959 replacement_code->entry()); |
| 4960 |
| 4961 unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 4962 unoptimized_code, pc_after - 4 * kInstrSize, replacement_code); |
| 4963 } |
| 4964 |
| 4965 |
| 4966 void BackEdgeTable::RevertAt(Code* unoptimized_code, |
| 4967 Address pc_after, |
| 4968 Code* interrupt_code) { |
| 4969 static const int kInstrSize = Assembler::kInstrSize; |
| 4970 // Restore the sltu instruction so beq can be taken again. |
| 4971 CodePatcher patcher(pc_after - 6 * kInstrSize, 1); |
| 4972 patcher.masm()->slt(at, a3, zero_reg); |
| 4973 // Restore the original call address. |
| 4974 Assembler::set_target_address_at(pc_after - 4 * kInstrSize, |
| 4975 interrupt_code->entry()); |
| 4976 |
| 4977 interrupt_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
| 4978 unoptimized_code, pc_after - 4 * kInstrSize, interrupt_code); |
| 4979 } |
| 4980 |
| 4981 |
| 4982 #ifdef DEBUG |
| 4983 BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
| 4984 Isolate* isolate, |
| 4985 Code* unoptimized_code, |
| 4986 Address pc_after) { |
| 4987 static const int kInstrSize = Assembler::kInstrSize; |
| 4988 ASSERT(Assembler::IsBeq(Assembler::instr_at(pc_after - 5 * kInstrSize))); |
| 4989 if (Assembler::IsAddImmediate( |
| 4990 Assembler::instr_at(pc_after - 6 * kInstrSize))) { |
| 4991 Code* osr_builtin = |
| 4992 isolate->builtins()->builtin(Builtins::kOnStackReplacement); |
| 4993 ASSERT(reinterpret_cast<uint32_t>( |
| 4994 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == |
| 4995 reinterpret_cast<uint32_t>(osr_builtin->entry())); |
| 4996 return ON_STACK_REPLACEMENT; |
| 4997 } else { |
| 4998 // Get the interrupt stub code object to match against from cache. |
| 4999 Code* interrupt_builtin = |
| 5000 isolate->builtins()->builtin(Builtins::kInterruptCheck); |
| 5001 ASSERT(reinterpret_cast<uint32_t>( |
| 5002 Assembler::target_address_at(pc_after - 4 * kInstrSize)) == |
| 5003 reinterpret_cast<uint32_t>(interrupt_builtin->entry())); |
| 5004 return INTERRUPT; |
| 5005 } |
| 5006 } |
| 5007 #endif // DEBUG |
| 5008 |
| 5009 |
| 4929 } } // namespace v8::internal | 5010 } } // namespace v8::internal |
| 4930 | 5011 |
| 4931 #endif // V8_TARGET_ARCH_MIPS | 5012 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |