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

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

Issue 6713074: Require an isolate parameter for most external reference creation to (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Further cleanup 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.h ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 334
335 // ----------------------------------------------------------------------------- 335 // -----------------------------------------------------------------------------
336 // Implementation of Assembler. 336 // Implementation of Assembler.
337 337
338 #ifdef GENERATED_CODE_COVERAGE 338 #ifdef GENERATED_CODE_COVERAGE
339 static void InitCoverageLog(); 339 static void InitCoverageLog();
340 #endif 340 #endif
341 341
342 Assembler::Assembler(void* buffer, int buffer_size) 342 Assembler::Assembler(void* buffer, int buffer_size)
343 : code_targets_(100), 343 : AssemblerBase(Isolate::Current()),
344 code_targets_(100),
344 positions_recorder_(this), 345 positions_recorder_(this),
345 emit_debug_code_(FLAG_debug_code) { 346 emit_debug_code_(FLAG_debug_code) {
346 Isolate* isolate = Isolate::Current();
347 if (buffer == NULL) { 347 if (buffer == NULL) {
348 // Do our own buffer management. 348 // Do our own buffer management.
349 if (buffer_size <= kMinimalBufferSize) { 349 if (buffer_size <= kMinimalBufferSize) {
350 buffer_size = kMinimalBufferSize; 350 buffer_size = kMinimalBufferSize;
351 351
352 if (isolate->assembler_spare_buffer() != NULL) { 352 if (isolate()->assembler_spare_buffer() != NULL) {
353 buffer = isolate->assembler_spare_buffer(); 353 buffer = isolate()->assembler_spare_buffer();
354 isolate->set_assembler_spare_buffer(NULL); 354 isolate()->set_assembler_spare_buffer(NULL);
355 } 355 }
356 } 356 }
357 if (buffer == NULL) { 357 if (buffer == NULL) {
358 buffer_ = NewArray<byte>(buffer_size); 358 buffer_ = NewArray<byte>(buffer_size);
359 } else { 359 } else {
360 buffer_ = static_cast<byte*>(buffer); 360 buffer_ = static_cast<byte*>(buffer);
361 } 361 }
362 buffer_size_ = buffer_size; 362 buffer_size_ = buffer_size;
363 own_buffer_ = true; 363 own_buffer_ = true;
364 } else { 364 } else {
(...skipping 20 matching lines...) Expand all
385 385
386 last_pc_ = NULL; 386 last_pc_ = NULL;
387 387
388 #ifdef GENERATED_CODE_COVERAGE 388 #ifdef GENERATED_CODE_COVERAGE
389 InitCoverageLog(); 389 InitCoverageLog();
390 #endif 390 #endif
391 } 391 }
392 392
393 393
394 Assembler::~Assembler() { 394 Assembler::~Assembler() {
395 Isolate* isolate = Isolate::Current();
396 if (own_buffer_) { 395 if (own_buffer_) {
397 if (isolate->assembler_spare_buffer() == NULL && 396 if (isolate()->assembler_spare_buffer() == NULL &&
398 buffer_size_ == kMinimalBufferSize) { 397 buffer_size_ == kMinimalBufferSize) {
399 isolate->set_assembler_spare_buffer(buffer_); 398 isolate()->set_assembler_spare_buffer(buffer_);
400 } else { 399 } else {
401 DeleteArray(buffer_); 400 DeleteArray(buffer_);
402 } 401 }
403 } 402 }
404 } 403 }
405 404
406 405
407 void Assembler::GetCode(CodeDesc* desc) { 406 void Assembler::GetCode(CodeDesc* desc) {
408 // Finalize code (at this point overflow() may be true, but the gap ensures 407 // Finalize code (at this point overflow() may be true, but the gap ensures
409 // that we are still not overlapping instructions and relocation info). 408 // that we are still not overlapping instructions and relocation info).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 int disp = pc_offset() - branch_pos; 473 int disp = pc_offset() - branch_pos;
475 ASSERT(is_int8(disp)); 474 ASSERT(is_int8(disp));
476 set_byte_at(branch_pos - sizeof(int8_t), disp); 475 set_byte_at(branch_pos - sizeof(int8_t), disp);
477 L->unresolved_branches_--; 476 L->unresolved_branches_--;
478 } 477 }
479 L->bind_to(pc_offset()); 478 L->bind_to(pc_offset());
480 } 479 }
481 480
482 481
483 void Assembler::GrowBuffer() { 482 void Assembler::GrowBuffer() {
484 Isolate* isolate = Isolate::Current();
485 ASSERT(buffer_overflow()); 483 ASSERT(buffer_overflow());
486 if (!own_buffer_) FATAL("external code buffer is too small"); 484 if (!own_buffer_) FATAL("external code buffer is too small");
487 485
488 // Compute new buffer size. 486 // Compute new buffer size.
489 CodeDesc desc; // the new buffer 487 CodeDesc desc; // the new buffer
490 if (buffer_size_ < 4*KB) { 488 if (buffer_size_ < 4*KB) {
491 desc.buffer_size = 4*KB; 489 desc.buffer_size = 4*KB;
492 } else { 490 } else {
493 desc.buffer_size = 2*buffer_size_; 491 desc.buffer_size = 2*buffer_size_;
494 } 492 }
(...skipping 18 matching lines...) Expand all
513 511
514 // Copy the data. 512 // Copy the data.
515 intptr_t pc_delta = desc.buffer - buffer_; 513 intptr_t pc_delta = desc.buffer - buffer_;
516 intptr_t rc_delta = (desc.buffer + desc.buffer_size) - 514 intptr_t rc_delta = (desc.buffer + desc.buffer_size) -
517 (buffer_ + buffer_size_); 515 (buffer_ + buffer_size_);
518 memmove(desc.buffer, buffer_, desc.instr_size); 516 memmove(desc.buffer, buffer_, desc.instr_size);
519 memmove(rc_delta + reloc_info_writer.pos(), 517 memmove(rc_delta + reloc_info_writer.pos(),
520 reloc_info_writer.pos(), desc.reloc_size); 518 reloc_info_writer.pos(), desc.reloc_size);
521 519
522 // Switch buffers. 520 // Switch buffers.
523 if (isolate->assembler_spare_buffer() == NULL && 521 if (isolate()->assembler_spare_buffer() == NULL &&
524 buffer_size_ == kMinimalBufferSize) { 522 buffer_size_ == kMinimalBufferSize) {
525 isolate->set_assembler_spare_buffer(buffer_); 523 isolate()->set_assembler_spare_buffer(buffer_);
526 } else { 524 } else {
527 DeleteArray(buffer_); 525 DeleteArray(buffer_);
528 } 526 }
529 buffer_ = desc.buffer; 527 buffer_ = desc.buffer;
530 buffer_size_ = desc.buffer_size; 528 buffer_size_ = desc.buffer_size;
531 pc_ += pc_delta; 529 pc_ += pc_delta;
532 if (last_pc_ != NULL) { 530 if (last_pc_ != NULL) {
533 last_pc_ += pc_delta; 531 last_pc_ += pc_delta;
534 } 532 }
535 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta, 533 reloc_info_writer.Reposition(reloc_info_writer.pos() + rc_delta,
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 void Assembler::cmpb_al(Immediate imm8) { 1026 void Assembler::cmpb_al(Immediate imm8) {
1029 ASSERT(is_int8(imm8.value_) || is_uint8(imm8.value_)); 1027 ASSERT(is_int8(imm8.value_) || is_uint8(imm8.value_));
1030 EnsureSpace ensure_space(this); 1028 EnsureSpace ensure_space(this);
1031 last_pc_ = pc_; 1029 last_pc_ = pc_;
1032 emit(0x3c); 1030 emit(0x3c);
1033 emit(imm8.value_); 1031 emit(imm8.value_);
1034 } 1032 }
1035 1033
1036 1034
1037 void Assembler::cpuid() { 1035 void Assembler::cpuid() {
1038 ASSERT(Isolate::Current()->cpu_features()->IsEnabled(CPUID)); 1036 ASSERT(isolate()->cpu_features()->IsEnabled(CPUID));
1039 EnsureSpace ensure_space(this); 1037 EnsureSpace ensure_space(this);
1040 last_pc_ = pc_; 1038 last_pc_ = pc_;
1041 emit(0x0F); 1039 emit(0x0F);
1042 emit(0xA2); 1040 emit(0xA2);
1043 } 1041 }
1044 1042
1045 1043
1046 void Assembler::cqo() { 1044 void Assembler::cqo() {
1047 EnsureSpace ensure_space(this); 1045 EnsureSpace ensure_space(this);
1048 last_pc_ = pc_; 1046 last_pc_ = pc_;
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
2379 void Assembler::fistp_s(const Operand& adr) { 2377 void Assembler::fistp_s(const Operand& adr) {
2380 EnsureSpace ensure_space(this); 2378 EnsureSpace ensure_space(this);
2381 last_pc_ = pc_; 2379 last_pc_ = pc_;
2382 emit_optional_rex_32(adr); 2380 emit_optional_rex_32(adr);
2383 emit(0xDB); 2381 emit(0xDB);
2384 emit_operand(3, adr); 2382 emit_operand(3, adr);
2385 } 2383 }
2386 2384
2387 2385
2388 void Assembler::fisttp_s(const Operand& adr) { 2386 void Assembler::fisttp_s(const Operand& adr) {
2389 ASSERT(Isolate::Current()->cpu_features()->IsEnabled(SSE3)); 2387 ASSERT(isolate()->cpu_features()->IsEnabled(SSE3));
2390 EnsureSpace ensure_space(this); 2388 EnsureSpace ensure_space(this);
2391 last_pc_ = pc_; 2389 last_pc_ = pc_;
2392 emit_optional_rex_32(adr); 2390 emit_optional_rex_32(adr);
2393 emit(0xDB); 2391 emit(0xDB);
2394 emit_operand(1, adr); 2392 emit_operand(1, adr);
2395 } 2393 }
2396 2394
2397 2395
2398 void Assembler::fisttp_d(const Operand& adr) { 2396 void Assembler::fisttp_d(const Operand& adr) {
2399 ASSERT(Isolate::Current()->cpu_features()->IsEnabled(SSE3)); 2397 ASSERT(isolate()->cpu_features()->IsEnabled(SSE3));
2400 EnsureSpace ensure_space(this); 2398 EnsureSpace ensure_space(this);
2401 last_pc_ = pc_; 2399 last_pc_ = pc_;
2402 emit_optional_rex_32(adr); 2400 emit_optional_rex_32(adr);
2403 emit(0xDD); 2401 emit(0xDD);
2404 emit_operand(1, adr); 2402 emit_operand(1, adr);
2405 } 2403 }
2406 2404
2407 2405
2408 void Assembler::fist_s(const Operand& adr) { 2406 void Assembler::fist_s(const Operand& adr) {
2409 EnsureSpace ensure_space(this); 2407 EnsureSpace ensure_space(this);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 last_pc_ = pc_; 2705 last_pc_ = pc_;
2708 emit(0x66); 2706 emit(0x66);
2709 emit_rex_64(src, dst); 2707 emit_rex_64(src, dst);
2710 emit(0x0F); 2708 emit(0x0F);
2711 emit(0x7E); 2709 emit(0x7E);
2712 emit_sse_operand(src, dst); 2710 emit_sse_operand(src, dst);
2713 } 2711 }
2714 2712
2715 2713
2716 void Assembler::movdqa(const Operand& dst, XMMRegister src) { 2714 void Assembler::movdqa(const Operand& dst, XMMRegister src) {
2717 ASSERT(Isolate::Current()->cpu_features()->IsEnabled(SSE2)); 2715 ASSERT(isolate()->cpu_features()->IsEnabled(SSE2));
2718 EnsureSpace ensure_space(this); 2716 EnsureSpace ensure_space(this);
2719 last_pc_ = pc_; 2717 last_pc_ = pc_;
2720 emit(0x66); 2718 emit(0x66);
2721 emit_rex_64(src, dst); 2719 emit_rex_64(src, dst);
2722 emit(0x0F); 2720 emit(0x0F);
2723 emit(0x7F); 2721 emit(0x7F);
2724 emit_sse_operand(src, dst); 2722 emit_sse_operand(src, dst);
2725 } 2723 }
2726 2724
2727 2725
2728 void Assembler::movdqa(XMMRegister dst, const Operand& src) { 2726 void Assembler::movdqa(XMMRegister dst, const Operand& src) {
2729 ASSERT(Isolate::Current()->cpu_features()->IsEnabled(SSE2)); 2727 ASSERT(isolate()->cpu_features()->IsEnabled(SSE2));
2730 EnsureSpace ensure_space(this); 2728 EnsureSpace ensure_space(this);
2731 last_pc_ = pc_; 2729 last_pc_ = pc_;
2732 emit(0x66); 2730 emit(0x66);
2733 emit_rex_64(dst, src); 2731 emit_rex_64(dst, src);
2734 emit(0x0F); 2732 emit(0x0F);
2735 emit(0x6F); 2733 emit(0x6F);
2736 emit_sse_operand(dst, src); 2734 emit_sse_operand(dst, src);
2737 } 2735 }
2738 2736
2739 2737
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 // specially coded on x64 means that it is a relative 32 bit address, as used 3160 // specially coded on x64 means that it is a relative 32 bit address, as used
3163 // by branch instructions. 3161 // by branch instructions.
3164 return (1 << rmode_) & kApplyMask; 3162 return (1 << rmode_) & kApplyMask;
3165 } 3163 }
3166 3164
3167 3165
3168 3166
3169 } } // namespace v8::internal 3167 } } // namespace v8::internal
3170 3168
3171 #endif // V8_TARGET_ARCH_X64 3169 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698