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

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

Issue 6794050: Revert "[Arguments] Merge (7442,7496] from bleeding_edge." (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
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
« no previous file with comments | « src/version.cc ('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(); 441 void Probe(bool portable);
442 442
443 // Check whether a feature is supported by the target CPU. 443 // Check whether a feature is supported by the target CPU.
444 static bool IsSupported(CpuFeature f) { 444 bool IsSupported(CpuFeature f) const {
445 ASSERT(initialized_);
446 if (f == SSE2 && !FLAG_enable_sse2) return false; 445 if (f == SSE2 && !FLAG_enable_sse2) return false;
447 if (f == SSE3 && !FLAG_enable_sse3) return false; 446 if (f == SSE3 && !FLAG_enable_sse3) return false;
448 if (f == CMOV && !FLAG_enable_cmov) return false; 447 if (f == CMOV && !FLAG_enable_cmov) return false;
449 if (f == RDTSC && !FLAG_enable_rdtsc) return false; 448 if (f == RDTSC && !FLAG_enable_rdtsc) return false;
450 if (f == SAHF && !FLAG_enable_sahf) return false; 449 if (f == SAHF && !FLAG_enable_sahf) return false;
451 return (supported_ & (V8_UINT64_C(1) << f)) != 0; 450 return (supported_ & (V8_UINT64_C(1) << f)) != 0;
452 } 451 }
453
454 #ifdef DEBUG
455 // Check whether a feature is currently enabled. 452 // Check whether a feature is currently enabled.
456 static bool IsEnabled(CpuFeature f) { 453 bool IsEnabled(CpuFeature f) const {
457 ASSERT(initialized_); 454 return (enabled_ & (V8_UINT64_C(1) << f)) != 0;
458 Isolate* isolate = Isolate::UncheckedCurrent();
459 if (isolate == NULL) {
460 // When no isolate is available, work as if we're running in
461 // release mode.
462 return IsSupported(f);
463 }
464 uint64_t enabled = isolate->enabled_cpu_features();
465 return (enabled & (V8_UINT64_C(1) << f)) != 0;
466 } 455 }
467 #endif
468
469 // Enable a specified feature within a scope. 456 // Enable a specified feature within a scope.
470 class Scope BASE_EMBEDDED { 457 class Scope BASE_EMBEDDED {
471 #ifdef DEBUG 458 #ifdef DEBUG
472 public: 459 public:
473 explicit Scope(CpuFeature f) { 460 explicit Scope(CpuFeature f)
474 uint64_t mask = V8_UINT64_C(1) << f; 461 : cpu_features_(Isolate::Current()->cpu_features()),
475 ASSERT(CpuFeatures::IsSupported(f)); 462 isolate_(Isolate::Current()) {
463 uint64_t mask = (V8_UINT64_C(1) << f);
464 ASSERT(cpu_features_->IsSupported(f));
476 ASSERT(!Serializer::enabled() || 465 ASSERT(!Serializer::enabled() ||
477 (CpuFeatures::found_by_runtime_probing_ & mask) == 0); 466 (cpu_features_->found_by_runtime_probing_ & mask) == 0);
478 isolate_ = Isolate::UncheckedCurrent(); 467 old_enabled_ = cpu_features_->enabled_;
479 old_enabled_ = 0; 468 cpu_features_->enabled_ |= mask;
480 if (isolate_ != NULL) {
481 old_enabled_ = isolate_->enabled_cpu_features();
482 isolate_->set_enabled_cpu_features(old_enabled_ | mask);
483 }
484 } 469 }
485 ~Scope() { 470 ~Scope() {
486 ASSERT_EQ(Isolate::UncheckedCurrent(), isolate_); 471 ASSERT_EQ(Isolate::Current(), isolate_);
487 if (isolate_ != NULL) { 472 cpu_features_->enabled_ = old_enabled_;
488 isolate_->set_enabled_cpu_features(old_enabled_);
489 }
490 } 473 }
491 private: 474 private:
475 uint64_t old_enabled_;
476 CpuFeatures* cpu_features_;
492 Isolate* isolate_; 477 Isolate* isolate_;
493 uint64_t old_enabled_;
494 #else 478 #else
495 public: 479 public:
496 explicit Scope(CpuFeature f) {} 480 explicit Scope(CpuFeature f) {}
497 #endif 481 #endif
498 }; 482 };
483 private:
484 CpuFeatures();
499 485
500 private:
501 // 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
502 // anyone checks, but they shouldn't need to check. 487 // anyone checks, but they shouldn't need to check.
503 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1): 488 // The required user mode extensions in X64 are (from AMD64 ABI Table A.1):
504 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall 489 // fpu, tsc, cx8, cmov, mmx, sse, sse2, fxsr, syscall
505 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV); 490 static const uint64_t kDefaultCpuFeatures = (1 << SSE2 | 1 << CMOV);
506 491
507 #ifdef DEBUG 492 uint64_t supported_;
508 static bool initialized_; 493 uint64_t enabled_;
509 #endif 494 uint64_t found_by_runtime_probing_;
510 static uint64_t supported_; 495
511 static uint64_t found_by_runtime_probing_; 496 friend class Isolate;
512 497
513 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); 498 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
514 }; 499 };
515 500
516 501
517 class Assembler : public AssemblerBase { 502 class Assembler : public AssemblerBase {
518 private: 503 private:
519 // We check before assembling an instruction that there is sufficient 504 // We check before assembling an instruction that there is sufficient
520 // space to write an instruction and its relocation information. 505 // space to write an instruction and its relocation information.
521 // 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
(...skipping 12 matching lines...) Expand all
534 // for a detailed comment on the layout (globals.h). 519 // for a detailed comment on the layout (globals.h).
535 // 520 //
536 // If the provided buffer is NULL, the assembler allocates and grows its own 521 // If the provided buffer is NULL, the assembler allocates and grows its own
537 // buffer, and buffer_size determines the initial buffer size. The buffer is 522 // buffer, and buffer_size determines the initial buffer size. The buffer is
538 // owned by the assembler and deallocated upon destruction of the assembler. 523 // owned by the assembler and deallocated upon destruction of the assembler.
539 // 524 //
540 // If the provided buffer is not NULL, the assembler uses the provided buffer 525 // If the provided buffer is not NULL, the assembler uses the provided buffer
541 // for code generation and assumes its size to be buffer_size. If the buffer 526 // for code generation and assumes its size to be buffer_size. If the buffer
542 // is too small, a fatal error occurs. No deallocation of the buffer is done 527 // is too small, a fatal error occurs. No deallocation of the buffer is done
543 // upon destruction of the assembler. 528 // upon destruction of the assembler.
544 Assembler(Isolate* isolate, void* buffer, int buffer_size); 529 Assembler(void* buffer, int buffer_size);
545 ~Assembler(); 530 ~Assembler();
546 531
547 // Overrides the default provided by FLAG_debug_code. 532 // Overrides the default provided by FLAG_debug_code.
548 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } 533 void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
549 534
550 // GetCode emits any pending (non-emitted) code and fills the descriptor 535 // GetCode emits any pending (non-emitted) code and fills the descriptor
551 // desc. GetCode() is idempotent; it returns the same result if no other 536 // desc. GetCode() is idempotent; it returns the same result if no other
552 // Assembler functions are invoked in between GetCode() calls. 537 // Assembler functions are invoked in between GetCode() calls.
553 void GetCode(CodeDesc* desc); 538 void GetCode(CodeDesc* desc);
554 539
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 private: 1608 private:
1624 Assembler* assembler_; 1609 Assembler* assembler_;
1625 #ifdef DEBUG 1610 #ifdef DEBUG
1626 int space_before_; 1611 int space_before_;
1627 #endif 1612 #endif
1628 }; 1613 };
1629 1614
1630 } } // namespace v8::internal 1615 } } // namespace v8::internal
1631 1616
1632 #endif // V8_X64_ASSEMBLER_X64_H_ 1617 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « src/version.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698