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

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

Issue 6597029: [Isolates] Merge r 6300:6500 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 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);
361 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 369 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
362 visitor->VisitExternalReference(target_reference_address()); 370 visitor->VisitExternalReference(target_reference_address());
371 CPU::FlushICache(pc_, sizeof(Address));
363 #ifdef ENABLE_DEBUGGER_SUPPORT 372 #ifdef ENABLE_DEBUGGER_SUPPORT
364 // TODO(isolates): Get a cached isolate below. 373 // TODO(isolates): Get a cached isolate below.
365 } else if (((RelocInfo::IsJSReturn(mode) && 374 } else if (((RelocInfo::IsJSReturn(mode) &&
366 IsPatchedReturnSequence()) || 375 IsPatchedReturnSequence()) ||
367 (RelocInfo::IsDebugBreakSlot(mode) && 376 (RelocInfo::IsDebugBreakSlot(mode) &&
368 IsPatchedDebugBreakSlotSequence())) && 377 IsPatchedDebugBreakSlotSequence())) &&
369 Isolate::Current()->debug()->has_break_points()) { 378 Isolate::Current()->debug()->has_break_points()) {
370 visitor->VisitDebugTarget(this); 379 visitor->VisitDebugTarget(this);
371 #endif 380 #endif
372 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 381 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
373 visitor->VisitRuntimeEntry(this); 382 visitor->VisitRuntimeEntry(this);
374 } 383 }
375 } 384 }
376 385
377 386
378 template<typename StaticVisitor> 387 template<typename StaticVisitor>
379 void RelocInfo::Visit(Heap* heap) { 388 void RelocInfo::Visit(Heap* heap) {
380 RelocInfo::Mode mode = rmode(); 389 RelocInfo::Mode mode = rmode();
381 if (mode == RelocInfo::EMBEDDED_OBJECT) { 390 if (mode == RelocInfo::EMBEDDED_OBJECT) {
382 StaticVisitor::VisitPointer(heap, target_object_address()); 391 StaticVisitor::VisitPointer(heap, target_object_address());
392 CPU::FlushICache(pc_, sizeof(Address));
383 } else if (RelocInfo::IsCodeTarget(mode)) { 393 } else if (RelocInfo::IsCodeTarget(mode)) {
384 StaticVisitor::VisitCodeTarget(this); 394 StaticVisitor::VisitCodeTarget(this);
385 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { 395 } else if (mode == RelocInfo::EXTERNAL_REFERENCE) {
386 StaticVisitor::VisitExternalReference(target_reference_address()); 396 StaticVisitor::VisitExternalReference(target_reference_address());
397 CPU::FlushICache(pc_, sizeof(Address));
387 #ifdef ENABLE_DEBUGGER_SUPPORT 398 #ifdef ENABLE_DEBUGGER_SUPPORT
388 } else if (heap->isolate()->debug()->has_break_points() && 399 } else if (heap->isolate()->debug()->has_break_points() &&
389 ((RelocInfo::IsJSReturn(mode) && 400 ((RelocInfo::IsJSReturn(mode) &&
390 IsPatchedReturnSequence()) || 401 IsPatchedReturnSequence()) ||
391 (RelocInfo::IsDebugBreakSlot(mode) && 402 (RelocInfo::IsDebugBreakSlot(mode) &&
392 IsPatchedDebugBreakSlotSequence()))) { 403 IsPatchedDebugBreakSlotSequence()))) {
393 StaticVisitor::VisitDebugTarget(this); 404 StaticVisitor::VisitDebugTarget(this);
394 #endif 405 #endif
395 } else if (mode == RelocInfo::RUNTIME_ENTRY) { 406 } else if (mode == RelocInfo::RUNTIME_ENTRY) {
396 StaticVisitor::VisitRuntimeEntry(this); 407 StaticVisitor::VisitRuntimeEntry(this);
(...skipping 11 matching lines...) Expand all
408 rex_ |= rm_reg.high_bit(); 419 rex_ |= rm_reg.high_bit();
409 } 420 }
410 421
411 422
412 void Operand::set_sib(ScaleFactor scale, Register index, Register base) { 423 void Operand::set_sib(ScaleFactor scale, Register index, Register base) {
413 ASSERT(len_ == 1); 424 ASSERT(len_ == 1);
414 ASSERT(is_uint2(scale)); 425 ASSERT(is_uint2(scale));
415 // Use SIB with no index register only for base rsp or r12. Otherwise we 426 // Use SIB with no index register only for base rsp or r12. Otherwise we
416 // would skip the SIB byte entirely. 427 // would skip the SIB byte entirely.
417 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12)); 428 ASSERT(!index.is(rsp) || base.is(rsp) || base.is(r12));
418 buf_[1] = scale << 6 | index.low_bits() << 3 | base.low_bits(); 429 buf_[1] = (scale << 6) | (index.low_bits() << 3) | base.low_bits();
419 rex_ |= index.high_bit() << 1 | base.high_bit(); 430 rex_ |= index.high_bit() << 1 | base.high_bit();
420 len_ = 2; 431 len_ = 2;
421 } 432 }
422 433
423 void Operand::set_disp8(int disp) { 434 void Operand::set_disp8(int disp) {
424 ASSERT(is_int8(disp)); 435 ASSERT(is_int8(disp));
425 ASSERT(len_ == 1 || len_ == 2); 436 ASSERT(len_ == 1 || len_ == 2);
426 int8_t* p = reinterpret_cast<int8_t*>(&buf_[len_]); 437 int8_t* p = reinterpret_cast<int8_t*>(&buf_[len_]);
427 *p = disp; 438 *p = disp;
428 len_ += sizeof(int8_t); 439 len_ += sizeof(int8_t);
429 } 440 }
430 441
431 void Operand::set_disp32(int disp) { 442 void Operand::set_disp32(int disp) {
432 ASSERT(len_ == 1 || len_ == 2); 443 ASSERT(len_ == 1 || len_ == 2);
433 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]); 444 int32_t* p = reinterpret_cast<int32_t*>(&buf_[len_]);
434 *p = disp; 445 *p = disp;
435 len_ += sizeof(int32_t); 446 len_ += sizeof(int32_t);
436 } 447 }
437 448
438 449
439 } } // namespace v8::internal 450 } } // namespace v8::internal
440 451
441 #endif // V8_X64_ASSEMBLER_X64_INL_H_ 452 #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