Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 173568: Add allocation support to x64 macro assembler (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ native
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 int token_offset = Context::kHeaderSize + 1197 int token_offset = Context::kHeaderSize +
1198 Context::SECURITY_TOKEN_INDEX * kPointerSize; 1198 Context::SECURITY_TOKEN_INDEX * kPointerSize;
1199 movq(scratch, FieldOperand(scratch, token_offset)); 1199 movq(scratch, FieldOperand(scratch, token_offset));
1200 cmpq(scratch, FieldOperand(kScratchRegister, token_offset)); 1200 cmpq(scratch, FieldOperand(kScratchRegister, token_offset));
1201 j(not_equal, miss); 1201 j(not_equal, miss);
1202 1202
1203 bind(&same_contexts); 1203 bind(&same_contexts);
1204 } 1204 }
1205 1205
1206 1206
1207 void MacroAssembler::LoadAllocationTopHelper(
1208 Register result,
1209 Register result_end,
1210 Register scratch,
1211 bool result_contains_top_on_entry) {
1212 ExternalReference new_space_allocation_top =
1213 ExternalReference::new_space_allocation_top_address();
1214
1215 // Just return if allocation top is already known.
1216 if (result_contains_top_on_entry) {
1217 // No use of scratch if allocation top is provided.
1218 ASSERT(scratch.is(no_reg));
1219 return;
1220 }
1221
1222 // Move address of new object to result. Use scratch register if available.
1223 if (scratch.is(no_reg)) {
1224 movq(kScratchRegister, new_space_allocation_top);
1225 movq(result, Operand(kScratchRegister, 0));
1226 } else {
1227 ASSERT(!scratch.is(result_end));
1228 movq(scratch, new_space_allocation_top);
1229 movq(result, Operand(scratch, 0));
1230 }
1231 }
1232
1233
1234 void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
1235 Register scratch) {
1236 ExternalReference new_space_allocation_top =
1237 ExternalReference::new_space_allocation_top_address();
1238
1239 // Update new top.
1240 if (result_end.is(rax)) {
1241 // rax can be stored directly to a memory location.
1242 store_rax(new_space_allocation_top);
1243 } else {
1244 // Register required - use scratch provided if available.
1245 if (scratch.is(no_reg)) {
1246 movq(kScratchRegister, new_space_allocation_top);
1247 movq(Operand(kScratchRegister, 0), result_end);
1248 } else {
1249 movq(Operand(scratch, 0), result_end);
1250 }
1251 }
1252 }
1253
1254
1255 void MacroAssembler::AllocateObjectInNewSpace(
1256 int object_size,
1257 Register result,
1258 Register result_end,
1259 Register scratch,
1260 Label* gc_required,
1261 bool result_contains_top_on_entry) {
1262 ASSERT(!result.is(result_end));
1263
1264 // Load address of new object into result.
1265 LoadAllocationTopHelper(result,
1266 result_end,
1267 scratch,
1268 result_contains_top_on_entry);
1269
1270 // Calculate new top and bail out if new space is exhausted.
1271 ExternalReference new_space_allocation_limit =
1272 ExternalReference::new_space_allocation_limit_address();
1273 lea(result_end, Operand(result, object_size));
1274 movq(kScratchRegister, new_space_allocation_limit);
1275 cmpq(result_end, Operand(kScratchRegister, 0));
1276 j(above, gc_required);
1277
1278 // Update allocation top.
1279 UpdateAllocationTopHelper(result_end, scratch);
1280 }
1281
1282
1283 void MacroAssembler::AllocateObjectInNewSpace(
1284 int header_size,
1285 ScaleFactor element_size,
1286 Register element_count,
1287 Register result,
1288 Register result_end,
1289 Register scratch,
1290 Label* gc_required,
1291 bool result_contains_top_on_entry) {
1292 ASSERT(!result.is(result_end));
1293
1294 // Load address of new object into result.
1295 LoadAllocationTopHelper(result,
1296 result_end,
1297 scratch,
1298 result_contains_top_on_entry);
1299
1300 // Calculate new top and bail out if new space is exhausted.
1301 ExternalReference new_space_allocation_limit =
1302 ExternalReference::new_space_allocation_limit_address();
1303 lea(result_end, Operand(result, element_count, element_size, header_size));
1304 movq(kScratchRegister, new_space_allocation_limit);
1305 cmpq(result_end, Operand(kScratchRegister, 0));
1306 j(above, gc_required);
1307
1308 // Update allocation top.
1309 UpdateAllocationTopHelper(result_end, scratch);
1310 }
1311
1312
1313 void MacroAssembler::AllocateObjectInNewSpace(
1314 Register object_size,
1315 Register result,
1316 Register result_end,
1317 Register scratch,
1318 Label* gc_required,
1319 bool result_contains_top_on_entry) {
1320
1321 // Load address of new object into result.
1322 LoadAllocationTopHelper(result,
1323 result_end,
1324 scratch,
1325 result_contains_top_on_entry);
1326
1327
1328 // Calculate new top and bail out if new space is exhausted.
1329 ExternalReference new_space_allocation_limit =
1330 ExternalReference::new_space_allocation_limit_address();
1331 if (!object_size.is(result_end)) {
1332 movq(result_end, object_size);
1333 }
1334 addq(result_end, result);
1335 movq(kScratchRegister, new_space_allocation_limit);
1336 cmpq(result_end, Operand(kScratchRegister, 0));
1337 j(above, gc_required);
1338
1339 // Update allocation top.
1340 UpdateAllocationTopHelper(result_end, scratch);
1341 }
1342
1343
1344 void MacroAssembler::UndoAllocationInNewSpace(Register object) {
1345 ExternalReference new_space_allocation_top =
1346 ExternalReference::new_space_allocation_top_address();
1347
1348 // Make sure the object has no tag before resetting top.
1349 and_(object, Immediate(~kHeapObjectTagMask));
1350 movq(kScratchRegister, new_space_allocation_top);
1351 #ifdef DEBUG
1352 cmpq(object, Operand(kScratchRegister, 0));
1353 Check(below, "Undo allocation of non allocated memory");
1354 #endif
1355 movq(Operand(kScratchRegister, 0), object);
1356 }
1357
1358
1207 } } // namespace v8::internal 1359 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698