| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Compute number of region covering addr. See Page::GetRegionNumberForAddress | 67 // Compute number of region covering addr. See Page::GetRegionNumberForAddress |
| 68 // method for more details. | 68 // method for more details. |
| 69 and_(addr, Page::kPageAlignmentMask); | 69 and_(addr, Page::kPageAlignmentMask); |
| 70 shr(addr, Page::kRegionSizeLog2); | 70 shr(addr, Page::kRegionSizeLog2); |
| 71 | 71 |
| 72 // Set dirty mark for region. | 72 // Set dirty mark for region. |
| 73 bts(Operand(object, Page::kDirtyFlagOffset), addr); | 73 bts(Operand(object, Page::kDirtyFlagOffset), addr); |
| 74 } | 74 } |
| 75 | 75 |
| 76 | 76 |
| 77 void MacroAssembler::InNewSpace(Register object, | |
| 78 Register scratch, | |
| 79 Condition cc, | |
| 80 Label* branch) { | |
| 81 ASSERT(cc == equal || cc == not_equal); | |
| 82 if (Serializer::enabled()) { | |
| 83 // Can't do arithmetic on external references if it might get serialized. | |
| 84 mov(scratch, Operand(object)); | |
| 85 // The mask isn't really an address. We load it as an external reference in | |
| 86 // case the size of the new space is different between the snapshot maker | |
| 87 // and the running system. | |
| 88 and_(Operand(scratch), Immediate(ExternalReference::new_space_mask())); | |
| 89 cmp(Operand(scratch), Immediate(ExternalReference::new_space_start())); | |
| 90 j(cc, branch); | |
| 91 } else { | |
| 92 int32_t new_space_start = reinterpret_cast<int32_t>( | |
| 93 ExternalReference::new_space_start().address()); | |
| 94 lea(scratch, Operand(object, -new_space_start)); | |
| 95 and_(scratch, HEAP->NewSpaceMask()); | |
| 96 j(cc, branch); | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 | |
| 101 void MacroAssembler::RecordWrite(Register object, | 77 void MacroAssembler::RecordWrite(Register object, |
| 102 int offset, | 78 int offset, |
| 103 Register value, | 79 Register value, |
| 104 Register scratch) { | 80 Register scratch) { |
| 105 // The compiled code assumes that record write doesn't change the | 81 // The compiled code assumes that record write doesn't change the |
| 106 // context register, so we check that none of the clobbered | 82 // context register, so we check that none of the clobbered |
| 107 // registers are esi. | 83 // registers are esi. |
| 108 ASSERT(!object.is(esi) && !value.is(esi) && !scratch.is(esi)); | 84 ASSERT(!object.is(esi) && !value.is(esi) && !scratch.is(esi)); |
| 109 | 85 |
| 110 // First, check if a write barrier is even needed. The tests below | 86 // First, check if a write barrier is even needed. The tests below |
| 111 // catch stores of Smis and stores into young gen. | 87 // catch stores of Smis and stores into young gen. |
| 112 Label done; | 88 NearLabel done; |
| 113 | 89 |
| 114 // Skip barrier if writing a smi. | 90 // Skip barrier if writing a smi. |
| 115 ASSERT_EQ(0, kSmiTag); | 91 ASSERT_EQ(0, kSmiTag); |
| 116 test(value, Immediate(kSmiTagMask)); | 92 test(value, Immediate(kSmiTagMask)); |
| 117 j(zero, &done); | 93 j(zero, &done); |
| 118 | 94 |
| 119 InNewSpace(object, value, equal, &done); | 95 InNewSpace(object, value, equal, &done); |
| 120 | 96 |
| 121 // The offset is relative to a tagged or untagged HeapObject pointer, | 97 // The offset is relative to a tagged or untagged HeapObject pointer, |
| 122 // so either offset or offset + kHeapObjectTag must be a | 98 // so either offset or offset + kHeapObjectTag must be a |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 | 1188 |
| 1213 | 1189 |
| 1214 MaybeObject* MacroAssembler::TryTailCallRuntime(Runtime::FunctionId fid, | 1190 MaybeObject* MacroAssembler::TryTailCallRuntime(Runtime::FunctionId fid, |
| 1215 int num_arguments, | 1191 int num_arguments, |
| 1216 int result_size) { | 1192 int result_size) { |
| 1217 return TryTailCallExternalReference( | 1193 return TryTailCallExternalReference( |
| 1218 ExternalReference(fid), num_arguments, result_size); | 1194 ExternalReference(fid), num_arguments, result_size); |
| 1219 } | 1195 } |
| 1220 | 1196 |
| 1221 | 1197 |
| 1222 // If true, a Handle<T> passed by value is passed and returned by | 1198 // If true, a Handle<T> returned by value from a function with cdecl calling |
| 1223 // using the location_ field directly. If false, it is passed and | 1199 // convention will be returned directly as a value of location_ field in a |
| 1224 // returned as a pointer to a handle. | 1200 // register eax. |
| 1225 #ifdef USING_BSD_ABI | 1201 // If false, it is returned as a pointer to a preallocated by caller memory |
| 1226 static const bool kPassHandlesDirectly = true; | 1202 // region. Pointer to this region should be passed to a function as an |
| 1203 // implicit first argument. |
| 1204 #if defined(USING_BSD_ABI) || defined(__MINGW32__) |
| 1205 static const bool kReturnHandlesDirectly = true; |
| 1227 #else | 1206 #else |
| 1228 static const bool kPassHandlesDirectly = false; | 1207 static const bool kReturnHandlesDirectly = false; |
| 1229 #endif | 1208 #endif |
| 1230 | 1209 |
| 1231 | 1210 |
| 1232 Operand ApiParameterOperand(int index) { | 1211 Operand ApiParameterOperand(int index) { |
| 1233 return Operand(esp, (index + (kPassHandlesDirectly ? 0 : 1)) * kPointerSize); | 1212 return Operand( |
| 1213 esp, (index + (kReturnHandlesDirectly ? 0 : 1)) * kPointerSize); |
| 1234 } | 1214 } |
| 1235 | 1215 |
| 1236 | 1216 |
| 1237 void MacroAssembler::PrepareCallApiFunction(int argc, Register scratch) { | 1217 void MacroAssembler::PrepareCallApiFunction(int argc, Register scratch) { |
| 1238 if (kPassHandlesDirectly) { | 1218 if (kReturnHandlesDirectly) { |
| 1239 EnterApiExitFrame(argc); | 1219 EnterApiExitFrame(argc); |
| 1240 // When handles as passed directly we don't have to allocate extra | 1220 // When handles are returned directly we don't have to allocate extra |
| 1241 // space for and pass an out parameter. | 1221 // space for and pass an out parameter. |
| 1242 } else { | 1222 } else { |
| 1243 // We allocate two additional slots: return value and pointer to it. | 1223 // We allocate two additional slots: return value and pointer to it. |
| 1244 EnterApiExitFrame(argc + 2); | 1224 EnterApiExitFrame(argc + 2); |
| 1245 | 1225 |
| 1246 // The argument slots are filled as follows: | 1226 // The argument slots are filled as follows: |
| 1247 // | 1227 // |
| 1248 // n + 1: output cell | 1228 // n + 1: output cell |
| 1249 // n: arg n | 1229 // n: arg n |
| 1250 // ... | 1230 // ... |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1275 ExternalReference::handle_scope_level_address(); | 1255 ExternalReference::handle_scope_level_address(); |
| 1276 | 1256 |
| 1277 // Allocate HandleScope in callee-save registers. | 1257 // Allocate HandleScope in callee-save registers. |
| 1278 mov(ebx, Operand::StaticVariable(next_address)); | 1258 mov(ebx, Operand::StaticVariable(next_address)); |
| 1279 mov(edi, Operand::StaticVariable(limit_address)); | 1259 mov(edi, Operand::StaticVariable(limit_address)); |
| 1280 add(Operand::StaticVariable(level_address), Immediate(1)); | 1260 add(Operand::StaticVariable(level_address), Immediate(1)); |
| 1281 | 1261 |
| 1282 // Call the api function! | 1262 // Call the api function! |
| 1283 call(function->address(), RelocInfo::RUNTIME_ENTRY); | 1263 call(function->address(), RelocInfo::RUNTIME_ENTRY); |
| 1284 | 1264 |
| 1285 if (!kPassHandlesDirectly) { | 1265 if (!kReturnHandlesDirectly) { |
| 1286 // The returned value is a pointer to the handle holding the result. | 1266 // The returned value is a pointer to the handle holding the result. |
| 1287 // Dereference this to get to the location. | 1267 // Dereference this to get to the location. |
| 1288 mov(eax, Operand(eax, 0)); | 1268 mov(eax, Operand(eax, 0)); |
| 1289 } | 1269 } |
| 1290 | 1270 |
| 1291 Label empty_handle; | 1271 Label empty_handle; |
| 1292 Label prologue; | 1272 Label prologue; |
| 1293 Label promote_scheduled_exception; | 1273 Label promote_scheduled_exception; |
| 1294 Label delete_allocated_handles; | 1274 Label delete_allocated_handles; |
| 1295 Label leave_exit_frame; | 1275 Label leave_exit_frame; |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 | 1904 |
| 1925 // Check that the code was patched as expected. | 1905 // Check that the code was patched as expected. |
| 1926 ASSERT(masm_.pc_ == address_ + size_); | 1906 ASSERT(masm_.pc_ == address_ + size_); |
| 1927 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 1907 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
| 1928 } | 1908 } |
| 1929 | 1909 |
| 1930 | 1910 |
| 1931 } } // namespace v8::internal | 1911 } } // namespace v8::internal |
| 1932 | 1912 |
| 1933 #endif // V8_TARGET_ARCH_IA32 | 1913 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |