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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/vm-state-inl.h ('k') | src/x64/assembler-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 (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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 427
428 // CpuFeatures keeps track of which features are supported by the target CPU. 428 // CpuFeatures keeps track of which features are supported by the target CPU.
429 // Supported features must be enabled by a Scope before use. 429 // Supported features must be enabled by a Scope before use.
430 // Example: 430 // Example:
431 // if (CpuFeatures::IsSupported(SSE3)) { 431 // if (CpuFeatures::IsSupported(SSE3)) {
432 // CpuFeatures::Scope fscope(SSE3); 432 // CpuFeatures::Scope fscope(SSE3);
433 // // Generate SSE3 floating point code. 433 // // Generate SSE3 floating point code.
434 // } else { 434 // } else {
435 // // Generate standard x87 or SSE2 floating point code. 435 // // Generate standard x87 or SSE2 floating point code.
436 // } 436 // }
437 class CpuFeatures : public AllStatic { 437 class CpuFeatures {
438 public: 438 public:
439 // Detect features of the target CPU. Set safe defaults if the serializer 439 // Detect features of the target CPU. Set safe defaults if the serializer
440 // is enabled (snapshots must be portable). 440 // is enabled (snapshots must be portable).
441 static void Probe(bool portable); 441 void Probe(bool portable);
442
442 // Check whether a feature is supported by the target CPU. 443 // Check whether a feature is supported by the target CPU.
443 static bool IsSupported(CpuFeature f) { 444 bool IsSupported(CpuFeature f) const {
444 if (f == SSE2 && !FLAG_enable_sse2) return false; 445 if (f == SSE2 && !FLAG_enable_sse2) return false;
445 if (f == SSE3 && !FLAG_enable_sse3) return false; 446 if (f == SSE3 && !FLAG_enable_sse3) return false;
446 if (f == CMOV && !FLAG_enable_cmov) return false; 447 if (f == CMOV && !FLAG_enable_cmov) return false;
447 if (f == RDTSC && !FLAG_enable_rdtsc) return false; 448 if (f == RDTSC && !FLAG_enable_rdtsc) return false;
448 if (f == SAHF && !FLAG_enable_sahf) return false; 449 if (f == SAHF && !FLAG_enable_sahf) return false;
449 return (supported_ & (V8_UINT64_C(1) << f)) != 0; 450 return (supported_ & (V8_UINT64_C(1) << f)) != 0;
450 } 451 }
451 // Check whether a feature is currently enabled. 452 // Check whether a feature is currently enabled.
452 static bool IsEnabled(CpuFeature f) { 453 bool IsEnabled(CpuFeature f) const {
453 return (enabled_ & (V8_UINT64_C(1) << f)) != 0; 454 return (enabled_ & (V8_UINT64_C(1) << f)) != 0;
454 } 455 }
455 // Enable a specified feature within a scope. 456 // Enable a specified feature within a scope.
456 class Scope BASE_EMBEDDED { 457 class Scope BASE_EMBEDDED {
457 #ifdef DEBUG 458 #ifdef DEBUG
458 public: 459 public:
459 explicit Scope(CpuFeature f) { 460 explicit Scope(CpuFeature f)
461 : cpu_features_(Isolate::Current()->cpu_features()),
462 isolate_(Isolate::Current()) {
460 uint64_t mask = (V8_UINT64_C(1) << f); 463 uint64_t mask = (V8_UINT64_C(1) << f);
461 ASSERT(CpuFeatures::IsSupported(f)); 464 ASSERT(cpu_features_->IsSupported(f));
462 ASSERT(!Serializer::enabled() || (found_by_runtime_probing_ & mask) == 0); 465 ASSERT(!Serializer::enabled() ||
463 old_enabled_ = CpuFeatures::enabled_; 466 (cpu_features_->found_by_runtime_probing_ & mask) == 0);
464 CpuFeatures::enabled_ |= mask; 467 old_enabled_ = cpu_features_->enabled_;
468 cpu_features_->enabled_ |= mask;
465 } 469 }
466 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } 470 ~Scope() {
471 ASSERT_EQ(Isolate::Current(), isolate_);
472 cpu_features_->enabled_ = old_enabled_;
473 }
467 private: 474 private:
468 uint64_t old_enabled_; 475 uint64_t old_enabled_;
476 CpuFeatures* cpu_features_;
477 Isolate* isolate_;
469 #else 478 #else
470 public: 479 public:
471 explicit Scope(CpuFeature f) {} 480 explicit Scope(CpuFeature f) {}
472 #endif 481 #endif
473 }; 482 };
474 private: 483 private:
484 CpuFeatures();
485
475 // Safe defaults include SSE2 and CMOV for X64. It is always available, if 486 // Safe defaults include SSE2 and CMOV for X64. It is always available, if
476 // anyone checks, but they shouldn't need to check. 487 // anyone checks, but they shouldn't need to check.
488 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1):
489 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall
477 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV); 490 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV);
478 static uint64_t supported_; 491
479 static uint64_t enabled_; 492 uint64_t supported_;
480 static uint64_t found_by_runtime_probing_; 493 uint64_t enabled_;
494 uint64_t found_by_runtime_probing_;
495
496 friend class Isolate;
497
498 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
481 }; 499 };
482 500
483 501
484 class Assembler : public Malloced { 502 class Assembler : public Malloced {
485 private: 503 private:
486 // We check before assembling an instruction that there is sufficient 504 // We check before assembling an instruction that there is sufficient
487 // space to write an instruction and its relocation information. 505 // space to write an instruction and its relocation information.
488 // The relocation writer's position must be kGap bytes above the end of 506 // The relocation writer's position must be kGap bytes above the end of
489 // the generated instructions. This leaves enough space for the 507 // the generated instructions. This leaves enough space for the
490 // longest possible x64 instruction, 15 bytes, and the longest possible 508 // longest possible x64 instruction, 15 bytes, and the longest possible
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 friend class CodePatcher; 1560 friend class CodePatcher;
1543 friend class EnsureSpace; 1561 friend class EnsureSpace;
1544 friend class RegExpMacroAssemblerX64; 1562 friend class RegExpMacroAssemblerX64;
1545 1563
1546 // Code buffer: 1564 // Code buffer:
1547 // The buffer into which code and relocation info are generated. 1565 // The buffer into which code and relocation info are generated.
1548 byte* buffer_; 1566 byte* buffer_;
1549 int buffer_size_; 1567 int buffer_size_;
1550 // True if the assembler owns the buffer, false if buffer is external. 1568 // True if the assembler owns the buffer, false if buffer is external.
1551 bool own_buffer_; 1569 bool own_buffer_;
1552 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL.
1553 static byte* spare_buffer_;
1554 1570
1555 // code generation 1571 // code generation
1556 byte* pc_; // the program counter; moves forward 1572 byte* pc_; // the program counter; moves forward
1557 RelocInfoWriter reloc_info_writer; 1573 RelocInfoWriter reloc_info_writer;
1558 1574
1559 List< Handle<Code> > code_targets_; 1575 List< Handle<Code> > code_targets_;
1560 // push-pop elimination 1576 // push-pop elimination
1561 byte* last_pc_; 1577 byte* last_pc_;
1562 1578
1563 PositionsRecorder positions_recorder_; 1579 PositionsRecorder positions_recorder_;
(...skipping 27 matching lines...) Expand all
1591 private: 1607 private:
1592 Assembler* assembler_; 1608 Assembler* assembler_;
1593 #ifdef DEBUG 1609 #ifdef DEBUG
1594 int space_before_; 1610 int space_before_;
1595 #endif 1611 #endif
1596 }; 1612 };
1597 1613
1598 } } // namespace v8::internal 1614 } } // namespace v8::internal
1599 1615
1600 #endif // V8_X64_ASSEMBLER_X64_H_ 1616 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « 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