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

Side by Side Diff: src/x64/assembler-x64-inl.h

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 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/assembler-x64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 193
194 // ----------------------------------------------------------------------------- 194 // -----------------------------------------------------------------------------
195 // Implementation of RelocInfo 195 // Implementation of RelocInfo
196 196
197 // The modes possibly affected by apply must be in kApplyMask. 197 // The modes possibly affected by apply must be in kApplyMask.
198 void RelocInfo::apply(intptr_t delta) { 198 void RelocInfo::apply(intptr_t delta) {
199 if (IsInternalReference(rmode_)) { 199 if (IsInternalReference(rmode_)) {
200 // absolute code pointer inside code object moves with the code object. 200 // absolute code pointer inside code object moves with the code object.
201 Memory::Address_at(pc_) += static_cast<int32_t>(delta); 201 Memory::Address_at(pc_) += static_cast<int32_t>(delta);
202 CPU::FlushICache(pc_, sizeof(Address));
202 } else if (IsCodeTarget(rmode_)) { 203 } else if (IsCodeTarget(rmode_)) {
203 Memory::int32_at(pc_) -= static_cast<int32_t>(delta); 204 Memory::int32_at(pc_) -= static_cast<int32_t>(delta);
205 CPU::FlushICache(pc_, sizeof(int32_t));
204 } 206 }
205 } 207 }
206 208
207 209
208 Address RelocInfo::target_address() { 210 Address RelocInfo::target_address() {
209 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); 211 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
210 if (IsCodeTarget(rmode_)) { 212 if (IsCodeTarget(rmode_)) {
211 return Assembler::target_address_at(pc_); 213 return Assembler::target_address_at(pc_);
212 } else { 214 } else {
213 return Memory::Address_at(pc_); 215 return Memory::Address_at(pc_);
(...skipping 15 matching lines...) Expand all
229 } 231 }
230 } 232 }
231 233
232 234
233 void RelocInfo::set_target_address(Address target) { 235 void RelocInfo::set_target_address(Address target) {
234 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY); 236 ASSERT(IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY);
235 if (IsCodeTarget(rmode_)) { 237 if (IsCodeTarget(rmode_)) {
236 Assembler::set_target_address_at(pc_, target); 238 Assembler::set_target_address_at(pc_, target);
237 } else { 239 } else {
238 Memory::Address_at(pc_) = target; 240 Memory::Address_at(pc_) = target;
241 CPU::FlushICache(pc_, sizeof(Address));
239 } 242 }
240 } 243 }
241 244
242 245
243 Object* RelocInfo::target_object() { 246 Object* RelocInfo::target_object() {
244 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 247 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
245 return Memory::Object_at(pc_); 248 return Memory::Object_at(pc_);
246 } 249 }
247 250
248 251
(...skipping 15 matching lines...) Expand all
264 267
265 Address* RelocInfo::target_reference_address() { 268 Address* RelocInfo::target_reference_address() {
266 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE); 269 ASSERT(rmode_ == RelocInfo::EXTERNAL_REFERENCE);
267 return reinterpret_cast<Address*>(pc_); 270 return reinterpret_cast<Address*>(pc_);
268 } 271 }
269 272
270 273
271 void RelocInfo::set_target_object(Object* target) { 274 void RelocInfo::set_target_object(Object* target) {
272 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT); 275 ASSERT(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
273 *reinterpret_cast<Object**>(pc_) = target; 276 *reinterpret_cast<Object**>(pc_) = target;
277 CPU::FlushICache(pc_, sizeof(Address));
274 } 278 }
275 279
276 280
277 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() { 281 Handle<JSGlobalPropertyCell> RelocInfo::target_cell_handle() {
278 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 282 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
279 Address address = Memory::Address_at(pc_); 283 Address address = Memory::Address_at(pc_);
280 return Handle<JSGlobalPropertyCell>( 284 return Handle<JSGlobalPropertyCell>(
281 reinterpret_cast<JSGlobalPropertyCell**>(address)); 285 reinterpret_cast<JSGlobalPropertyCell**>(address));
282 } 286 }
283 287
284 288
285 JSGlobalPropertyCell* RelocInfo::target_cell() { 289 JSGlobalPropertyCell* RelocInfo::target_cell() {
286 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 290 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
287 Address address = Memory::Address_at(pc_); 291 Address address = Memory::Address_at(pc_);
288 Object* object = HeapObject::FromAddress( 292 Object* object = HeapObject::FromAddress(
289 address - JSGlobalPropertyCell::kValueOffset); 293 address - JSGlobalPropertyCell::kValueOffset);
290 return reinterpret_cast<JSGlobalPropertyCell*>(object); 294 return reinterpret_cast<JSGlobalPropertyCell*>(object);
291 } 295 }
292 296
293 297
294 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) { 298 void RelocInfo::set_target_cell(JSGlobalPropertyCell* cell) {
295 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL); 299 ASSERT(rmode_ == RelocInfo::GLOBAL_PROPERTY_CELL);
296 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset; 300 Address address = cell->address() + JSGlobalPropertyCell::kValueOffset;
297 Memory::Address_at(pc_) = address; 301 Memory::Address_at(pc_) = address;
302 CPU::FlushICache(pc_, sizeof(Address));
298 } 303 }
299 304
300 305
301 bool RelocInfo::IsPatchedReturnSequence() { 306 bool RelocInfo::IsPatchedReturnSequence() {
302 // The recognized call sequence is: 307 // The recognized call sequence is:
303 // movq(kScratchRegister, immediate64); call(kScratchRegister); 308 // movq(kScratchRegister, immediate64); call(kScratchRegister);
304 // It only needs to be distinguished from a return sequence 309 // It only needs to be distinguished from a return sequence
305 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6 310 // movq(rsp, rbp); pop(rbp); ret(n); int3 *6
306 // The 11th byte is int3 (0xCC) in the return sequence and 311 // The 11th byte is int3 (0xCC) in the return sequence and
307 // REX.WB (0x48+register bit) for the call sequence. 312 // REX.WB (0x48+register bit) for the call sequence.
(...skipping 16 matching lines...) Expand all
324 return Memory::Address_at( 329 return Memory::Address_at(
325 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset); 330 pc_ + Assembler::kRealPatchReturnSequenceAddressOffset);
326 } 331 }
327 332
328 333
329 void RelocInfo::set_call_address(Address target) { 334 void RelocInfo::set_call_address(Address target) {
330 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 335 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
331 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 336 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
332 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = 337 Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) =
333 target; 338 target;
339 CPU::FlushICache(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset,
340 sizeof(Address));
334 } 341 }
335 342
336 343
337 Object* RelocInfo::call_object() { 344 Object* RelocInfo::call_object() {
338 return *call_object_address(); 345 return *call_object_address();
339 } 346 }
340 347
341 348
342 void RelocInfo::set_call_object(Object* target) { 349 void RelocInfo::set_call_object(Object* target) {
343 *call_object_address() = target; 350 *call_object_address() = target;
344 } 351 }
345 352
346 353
347 Object** RelocInfo::call_object_address() { 354 Object** RelocInfo::call_object_address() {
348 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) || 355 ASSERT((IsJSReturn(rmode()) && IsPatchedReturnSequence()) ||
349 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); 356 (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence()));
350 return reinterpret_cast<Object**>( 357 return reinterpret_cast<Object**>(
351 pc_ + Assembler::kPatchReturnSequenceAddressOffset); 358 pc_ + Assembler::kPatchReturnSequenceAddressOffset);
352 } 359 }
353 360
354 361
355 void RelocInfo::Visit(ObjectVisitor* visitor) { 362 void RelocInfo::Visit(ObjectVisitor* visitor) {
356 RelocInfo::Mode mode = rmode(); 363 RelocInfo::Mode mode = rmode();
357 if (mode == RelocInfo::EMBEDDED_OBJECT) { 364 if (mode == RelocInfo::EMBEDDED_OBJECT) {
358 visitor->VisitPointer(target_object_address()); 365 visitor->VisitPointer(target_object_address());
366 CPU::FlushICache(pc_, sizeof(Address));
359 } else if (RelocInfo::IsCodeTarget(mode)) { 367 } else if (RelocInfo::IsCodeTarget(mode)) {
360 visitor->VisitCodeTarget(this); 368 visitor->VisitCodeTarget(this);
369 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
370 visitor->VisitGlobalPropertyCell(this);
361 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 371 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
362 visitor->VisitExternalReference(target_reference_address()); 372 visitor->VisitExternalReference(target_reference_address());
373 CPU::FlushICache(pc_, sizeof(Address));
363 #ifdef ENABLE_DEBUGGER_SUPPORT 374 #ifdef ENABLE_DEBUGGER_SUPPORT
364 } else if (Debug::has_break_points() && 375 } else if (Debug::has_break_points() &&
365 ((RelocInfo::IsJSReturn(mode) && 376 ((RelocInfo::IsJSReturn(mode) &&
366 IsPatchedReturnSequence()) || 377 IsPatchedReturnSequence()) ||
367 (RelocInfo::IsDebugBreakSlot(mode) && 378 (RelocInfo::IsDebugBreakSlot(mode) &&
368 IsPatchedDebugBreakSlotSequence()))) { 379 IsPatchedDebugBreakSlotSequence()))) {
369 visitor->VisitDebugTarget(this); 380 visitor->VisitDebugTarget(this);
370 #endif 381 #endif
371 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 382 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
372 visitor->VisitRuntimeEntry(this); 383 visitor->VisitRuntimeEntry(this);
373 } 384 }
374 } 385 }
375 386
376 387
377 template<typename StaticVisitor> 388 template<typename StaticVisitor>
378 void RelocInfo::Visit() { 389 void RelocInfo::Visit() {
379 RelocInfo::Mode mode = rmode(); 390 RelocInfo::Mode mode = rmode();
380 if (mode == RelocInfo::EMBEDDED_OBJECT) { 391 if (mode == RelocInfo::EMBEDDED_OBJECT) {
381 StaticVisitor::VisitPointer(target_object_address()); 392 StaticVisitor::VisitPointer(target_object_address());
393 CPU::FlushICache(pc_, sizeof(Address));
382 } else if (RelocInfo::IsCodeTarget(mode)) { 394 } else if (RelocInfo::IsCodeTarget(mode)) {
383 StaticVisitor::VisitCodeTarget(this); 395 StaticVisitor::VisitCodeTarget(this);
396 } else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
397 StaticVisitor::VisitGlobalPropertyCell(this);
384 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 398 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
385 StaticVisitor::VisitExternalReference(target_reference_address()); 399 StaticVisitor::VisitExternalReference(target_reference_address());
400 CPU::FlushICache(pc_, sizeof(Address));
386 #ifdef ENABLE_DEBUGGER_SUPPORT 401 #ifdef ENABLE_DEBUGGER_SUPPORT
387 } else if (Debug::has_break_points() && 402 } else if (Debug::has_break_points() &&
388 ((RelocInfo::IsJSReturn(mode) && 403 ((RelocInfo::IsJSReturn(mode) &&
389 IsPatchedReturnSequence()) || 404 IsPatchedReturnSequence()) ||
390 (RelocInfo::IsDebugBreakSlot(mode) && 405 (RelocInfo::IsDebugBreakSlot(mode) &&
391 IsPatchedDebugBreakSlotSequence()))) { 406 IsPatchedDebugBreakSlotSequence()))) {
392 StaticVisitor::VisitDebugTarget(this); 407 StaticVisitor::VisitDebugTarget(this);
393 #endif 408 #endif
394 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 409 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
395 StaticVisitor::VisitRuntimeEntry(this); 410 StaticVisitor::VisitRuntimeEntry(this);
(...skipping 11 matching lines...) Expand all
407 rex_ |= rm_reg.high_bit(); 422 rex_ |= rm_reg.high_bit();
408 } 423 }
409 424
410 425
411 void Operand::set_sib(ScaleFactor scale, Register index, Register base) { 426 void Operand::set_sib(ScaleFactor scale, Register index, Register base) {
412 ASSERT(len_ == 1); 427 ASSERT(len_ == 1);
413 ASSERT(is_uint2(scale)); 428 ASSERT(is_uint2(scale));
414 // Use SIB with no index register only for base rsp or r12. Otherwise we 429 // Use SIB with no index register only for base rsp or r12. Otherwise we
415 // would skip the SIB byte entirely. 430 // would skip the SIB byte entirely.
416 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12)); 431 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12));
417 buf_[1] = scale << 6 | index.low_bits() << 3 | base.low_bits(); 432 buf_[1] = (scale << 6) | (index.low_bits() << 3) | base.low_bits();
418 rex_ |= index.high_bit() << 1 | base.high_bit(); 433 rex_ |= index.high_bit() << 1 | base.high_bit();
419 len_ = 2; 434 len_ = 2;
420 } 435 }
421 436
422 void Operand::set_disp8(int disp) { 437 void Operand::set_disp8(int disp) {
423 ASSERT(is_int8(disp)); 438 ASSERT(is_int8(disp));
424 ASSERT(len_ == 1 || len_ == 2); 439 ASSERT(len_ == 1 || len_ == 2);
425 int8_t* p = reinterpret_cast<int8_t*>(&buf_[len_]); 440 int8_t* p = reinterpret_cast<int8_t*>(&buf_[len_]);
426 *p = disp; 441 *p = disp;
427 len_ += sizeof(int8_t); 442 len_ += sizeof(int8_t);
428 } 443 }
429 444
430 void Operand::set_disp32(int disp) { 445 void Operand::set_disp32(int disp) {
431 ASSERT(len_ == 1 || len_ == 2); 446 ASSERT(len_ == 1 || len_ == 2);
432 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); 447 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
433 *p = disp; 448 *p = disp;
434 len_ += sizeof(int32_t); 449 len_ += sizeof(int32_t);
435 } 450 }
436 451
437 452
438 } } // namespace v8::internal 453 } } // namespace v8::internal
439 454
440 #endif // V8_X64_ASSEMBLER_X64_INL_H_ 455 #endif // V8_X64_ASSEMBLER_X64_INL_H_
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698