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

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

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 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
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 433
434 // CpuFeatures keeps track of which features are supported by the target CPU. 434 // CpuFeatures keeps track of which features are supported by the target CPU.
435 // Supported features must be enabled by a Scope before use. 435 // Supported features must be enabled by a Scope before use.
436 // Example: 436 // Example:
437 // if (CpuFeatures::IsSupported(SSE3)) { 437 // if (CpuFeatures::IsSupported(SSE3)) {
438 // CpuFeatures::Scope fscope(SSE3); 438 // CpuFeatures::Scope fscope(SSE3);
439 // // Generate SSE3 floating point code. 439 // // Generate SSE3 floating point code.
440 // } else { 440 // } else {
441 // // Generate standard x87 or SSE2 floating point code. 441 // // Generate standard x87 or SSE2 floating point code.
442 // } 442 // }
443 class CpuFeatures : public AllStatic { 443 class CpuFeatures {
444 public: 444 public:
445 // Detect features of the target CPU. Set safe defaults if the serializer 445 // Detect features of the target CPU. Set safe defaults if the serializer
446 // is enabled (snapshots must be portable). 446 // is enabled (snapshots must be portable).
447 static void Probe(bool portable); 447 void Probe(bool portable);
448
448 // Check whether a feature is supported by the target CPU. 449 // Check whether a feature is supported by the target CPU.
449 static bool IsSupported(CpuFeature f) { 450 bool IsSupported(CpuFeature f) const {
450 if (f == SSE2 && !FLAG_enable_sse2) return false; 451 if (f == SSE2 && !FLAG_enable_sse2) return false;
451 if (f == SSE3 && !FLAG_enable_sse3) return false; 452 if (f == SSE3 && !FLAG_enable_sse3) return false;
452 if (f == CMOV && !FLAG_enable_cmov) return false; 453 if (f == CMOV && !FLAG_enable_cmov) return false;
453 if (f == RDTSC && !FLAG_enable_rdtsc) return false; 454 if (f == RDTSC && !FLAG_enable_rdtsc) return false;
454 if (f == SAHF && !FLAG_enable_sahf) return false; 455 if (f == SAHF && !FLAG_enable_sahf) return false;
455 return (supported_ & (V8_UINT64_C(1) << f)) != 0; 456 return (supported_ & (V8_UINT64_C(1) << f)) != 0;
456 } 457 }
457 // Check whether a feature is currently enabled. 458 // Check whether a feature is currently enabled.
458 static bool IsEnabled(CpuFeature f) { 459 bool IsEnabled(CpuFeature f) const {
459 return (enabled_ & (V8_UINT64_C(1) << f)) != 0; 460 return (enabled_ & (V8_UINT64_C(1) << f)) != 0;
460 } 461 }
461 // Enable a specified feature within a scope. 462 // Enable a specified feature within a scope.
462 class Scope BASE_EMBEDDED { 463 class Scope BASE_EMBEDDED {
463 #ifdef DEBUG 464 #ifdef DEBUG
464 public: 465 public:
465 explicit Scope(CpuFeature f) { 466 explicit Scope(CpuFeature f)
467 : cpu_features_(Isolate::Current()->cpu_features()),
468 isolate_(Isolate::Current()) {
466 uint64_t mask = (V8_UINT64_C(1) << f); 469 uint64_t mask = (V8_UINT64_C(1) << f);
467 ASSERT(CpuFeatures::IsSupported(f)); 470 ASSERT(cpu_features_->IsSupported(f));
468 ASSERT(!Serializer::enabled() || (found_by_runtime_probing_ & mask) == 0); 471 ASSERT(!Serializer::enabled() ||
469 old_enabled_ = CpuFeatures::enabled_; 472 (cpu_features_->found_by_runtime_probing_ & mask) == 0);
470 CpuFeatures::enabled_ |= mask; 473 old_enabled_ = cpu_features_->enabled_;
474 cpu_features_->enabled_ |= mask;
471 } 475 }
472 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } 476 ~Scope() {
477 ASSERT_EQ(Isolate::Current(), isolate_);
478 cpu_features_->enabled_ = old_enabled_;
479 }
473 private: 480 private:
474 uint64_t old_enabled_; 481 uint64_t old_enabled_;
482 CpuFeatures* cpu_features_;
483 Isolate* isolate_;
475 #else 484 #else
476 public: 485 public:
477 explicit Scope(CpuFeature f) {} 486 explicit Scope(CpuFeature f) {}
478 #endif 487 #endif
479 }; 488 };
480 private: 489 private:
490 CpuFeatures();
491
481 // Safe defaults include SSE2 and CMOV for X64. It is always available, if 492 // Safe defaults include SSE2 and CMOV for X64. It is always available, if
482 // anyone checks, but they shouldn't need to check. 493 // anyone checks, but they shouldn't need to check.
494 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1):
495 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall
483 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV); 496 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV);
484 static uint64_t supported_; 497
485 static uint64_t enabled_; 498 uint64_t supported_;
486 static uint64_t found_by_runtime_probing_; 499 uint64_t enabled_;
500 uint64_t found_by_runtime_probing_;
501
502 friend class Isolate;
503
504 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
487 }; 505 };
488 506
489 507
490 class Assembler : public Malloced { 508 class Assembler : public Malloced {
491 private: 509 private:
492 // We check before assembling an instruction that there is sufficient 510 // We check before assembling an instruction that there is sufficient
493 // space to write an instruction and its relocation information. 511 // space to write an instruction and its relocation information.
494 // The relocation writer's position must be kGap bytes above the end of 512 // The relocation writer's position must be kGap bytes above the end of
495 // the generated instructions. This leaves enough space for the 513 // the generated instructions. This leaves enough space for the
496 // longest possible x64 instruction, 15 bytes, and the longest possible 514 // longest possible x64 instruction, 15 bytes, and the longest possible
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 friend class CodePatcher; 1566 friend class CodePatcher;
1549 friend class EnsureSpace; 1567 friend class EnsureSpace;
1550 friend class RegExpMacroAssemblerX64; 1568 friend class RegExpMacroAssemblerX64;
1551 1569
1552 // Code buffer: 1570 // Code buffer:
1553 // The buffer into which code and relocation info are generated. 1571 // The buffer into which code and relocation info are generated.
1554 byte* buffer_; 1572 byte* buffer_;
1555 int buffer_size_; 1573 int buffer_size_;
1556 // True if the assembler owns the buffer, false if buffer is external. 1574 // True if the assembler owns the buffer, false if buffer is external.
1557 bool own_buffer_; 1575 bool own_buffer_;
1558 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL.
1559 static byte* spare_buffer_;
1560 1576
1561 // code generation 1577 // code generation
1562 byte* pc_; // the program counter; moves forward 1578 byte* pc_; // the program counter; moves forward
1563 RelocInfoWriter reloc_info_writer; 1579 RelocInfoWriter reloc_info_writer;
1564 1580
1565 List< Handle<Code> > code_targets_; 1581 List< Handle<Code> > code_targets_;
1566 // push-pop elimination 1582 // push-pop elimination
1567 byte* last_pc_; 1583 byte* last_pc_;
1568 1584
1569 PositionsRecorder positions_recorder_; 1585 PositionsRecorder positions_recorder_;
(...skipping 27 matching lines...) Expand all
1597 private: 1613 private:
1598 Assembler* assembler_; 1614 Assembler* assembler_;
1599 #ifdef DEBUG 1615 #ifdef DEBUG
1600 int space_before_; 1616 int space_before_;
1601 #endif 1617 #endif
1602 }; 1618 };
1603 1619
1604 } } // namespace v8::internal 1620 } } // namespace v8::internal
1605 1621
1606 #endif // V8_X64_ASSEMBLER_X64_H_ 1622 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« src/store-buffer.cc ('K') | « src/vm-state-inl.h ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698