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

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

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