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

Side by Side Diff: src/ia32/assembler-ia32.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/hydrogen-instructions.cc ('k') | src/ia32/assembler-ia32.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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 439
440 // CpuFeatures keeps track of which features are supported by the target CPU. 440 // CpuFeatures keeps track of which features are supported by the target CPU.
441 // Supported features must be enabled by a Scope before use. 441 // Supported features must be enabled by a Scope before use.
442 // Example: 442 // Example:
443 // if (CpuFeatures::IsSupported(SSE2)) { 443 // if (CpuFeatures::IsSupported(SSE2)) {
444 // CpuFeatures::Scope fscope(SSE2); 444 // CpuFeatures::Scope fscope(SSE2);
445 // // Generate SSE2 floating point code. 445 // // Generate SSE2 floating point code.
446 // } else { 446 // } else {
447 // // Generate standard x87 floating point code. 447 // // Generate standard x87 floating point code.
448 // } 448 // }
449 class CpuFeatures { 449 class CpuFeatures : public AllStatic {
450 public: 450 public:
451 // Detect features of the target CPU. If the portable flag is set, 451 // Detect features of the target CPU. Set safe defaults if the serializer
452 // the method sets safe defaults if the serializer is enabled 452 // is enabled (snapshots must be portable).
453 // (snapshots must be portable). 453 static void Probe();
454 void Probe(bool portable);
455 void Clear() { supported_ = 0; }
456 454
457 // Check whether a feature is supported by the target CPU. 455 // Check whether a feature is supported by the target CPU.
458 bool IsSupported(CpuFeature f) const { 456 static bool IsSupported(CpuFeature f) {
457 ASSERT(initialized_);
459 if (f == SSE2 && !FLAG_enable_sse2) return false; 458 if (f == SSE2 && !FLAG_enable_sse2) return false;
460 if (f == SSE3 && !FLAG_enable_sse3) return false; 459 if (f == SSE3 && !FLAG_enable_sse3) return false;
461 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; 460 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false;
462 if (f == CMOV && !FLAG_enable_cmov) return false; 461 if (f == CMOV && !FLAG_enable_cmov) return false;
463 if (f == RDTSC && !FLAG_enable_rdtsc) return false; 462 if (f == RDTSC && !FLAG_enable_rdtsc) return false;
464 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; 463 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0;
465 } 464 }
465
466 #ifdef DEBUG
466 // Check whether a feature is currently enabled. 467 // Check whether a feature is currently enabled.
467 bool IsEnabled(CpuFeature f) const { 468 static bool IsEnabled(CpuFeature f) {
468 return (enabled_ & (static_cast<uint64_t>(1) << f)) != 0; 469 ASSERT(initialized_);
470 Isolate* isolate = Isolate::UncheckedCurrent();
471 if (isolate == NULL) {
472 // When no isolate is available, work as if we're running in
473 // release mode.
474 return IsSupported(f);
475 }
476 uint64_t enabled = isolate->enabled_cpu_features();
477 return (enabled & (static_cast<uint64_t>(1) << f)) != 0;
469 } 478 }
479 #endif
480
470 // Enable a specified feature within a scope. 481 // Enable a specified feature within a scope.
471 class Scope BASE_EMBEDDED { 482 class Scope BASE_EMBEDDED {
472 #ifdef DEBUG 483 #ifdef DEBUG
473 public: 484 public:
474 explicit Scope(CpuFeature f) 485 explicit Scope(CpuFeature f) {
475 : cpu_features_(Isolate::Current()->cpu_features()),
476 isolate_(Isolate::Current()) {
477 uint64_t mask = static_cast<uint64_t>(1) << f; 486 uint64_t mask = static_cast<uint64_t>(1) << f;
478 ASSERT(cpu_features_->IsSupported(f)); 487 ASSERT(CpuFeatures::IsSupported(f));
479 ASSERT(!Serializer::enabled() || 488 ASSERT(!Serializer::enabled() ||
480 (cpu_features_->found_by_runtime_probing_ & mask) == 0); 489 (CpuFeatures::found_by_runtime_probing_ & mask) == 0);
481 old_enabled_ = cpu_features_->enabled_; 490 isolate_ = Isolate::UncheckedCurrent();
482 cpu_features_->enabled_ |= mask; 491 old_enabled_ = 0;
492 if (isolate_ != NULL) {
493 old_enabled_ = isolate_->enabled_cpu_features();
494 isolate_->set_enabled_cpu_features(old_enabled_ | mask);
495 }
483 } 496 }
484 ~Scope() { 497 ~Scope() {
485 ASSERT_EQ(Isolate::Current(), isolate_); 498 ASSERT_EQ(Isolate::UncheckedCurrent(), isolate_);
486 cpu_features_->enabled_ = old_enabled_; 499 if (isolate_ != NULL) {
500 isolate_->set_enabled_cpu_features(old_enabled_);
501 }
487 } 502 }
488 private: 503 private:
504 Isolate* isolate_;
489 uint64_t old_enabled_; 505 uint64_t old_enabled_;
490 CpuFeatures* cpu_features_;
491 Isolate* isolate_;
492 #else 506 #else
493 public: 507 public:
494 explicit Scope(CpuFeature f) {} 508 explicit Scope(CpuFeature f) {}
495 #endif 509 #endif
496 }; 510 };
497 511
512 class TryForceFeatureScope BASE_EMBEDDED {
513 public:
514 explicit TryForceFeatureScope(CpuFeature f)
515 : old_supported_(CpuFeatures::supported_) {
516 if (CanForce()) {
517 CpuFeatures::supported_ |= (static_cast<uint64_t>(1) << f);
518 }
519 }
520
521 ~TryForceFeatureScope() {
522 if (CanForce()) {
523 CpuFeatures::supported_ = old_supported_;
524 }
525 }
526
527 private:
528 static bool CanForce() {
529 // It's only safe to temporarily force support of CPU features
530 // when there's only a single isolate, which is guaranteed when
531 // the serializer is enabled.
532 return Serializer::enabled();
533 }
534
535 const uint64_t old_supported_;
536 };
537
498 private: 538 private:
499 CpuFeatures(); 539 #ifdef DEBUG
500 540 static bool initialized_;
501 uint64_t supported_; 541 #endif
502 uint64_t enabled_; 542 static uint64_t supported_;
503 uint64_t found_by_runtime_probing_; 543 static uint64_t found_by_runtime_probing_;
504
505 friend class Isolate;
506 544
507 DISALLOW_COPY_AND_ASSIGN(CpuFeatures); 545 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
508 }; 546 };
509 547
510 548
511 class Assembler : public AssemblerBase { 549 class Assembler : public AssemblerBase {
512 private: 550 private:
513 // We check before assembling an instruction that there is sufficient 551 // We check before assembling an instruction that there is sufficient
514 // space to write an instruction and its relocation information. 552 // space to write an instruction and its relocation information.
515 // The relocation writer's position must be kGap bytes above the end of 553 // The relocation writer's position must be kGap bytes above the end of
(...skipping 12 matching lines...) Expand all
528 // for a detailed comment on the layout (globals.h). 566 // for a detailed comment on the layout (globals.h).
529 // 567 //
530 // If the provided buffer is NULL, the assembler allocates and grows its own 568 // If the provided buffer is NULL, the assembler allocates and grows its own
531 // buffer, and buffer_size determines the initial buffer size. The buffer is 569 // buffer, and buffer_size determines the initial buffer size. The buffer is
532 // owned by the assembler and deallocated upon destruction of the assembler. 570 // owned by the assembler and deallocated upon destruction of the assembler.
533 // 571 //
534 // If the provided buffer is not NULL, the assembler uses the provided buffer 572 // If the provided buffer is not NULL, the assembler uses the provided buffer
535 // for code generation and assumes its size to be buffer_size. If the buffer 573 // for code generation and assumes its size to be buffer_size. If the buffer
536 // is too small, a fatal error occurs. No deallocation of the buffer is done 574 // is too small, a fatal error occurs. No deallocation of the buffer is done
537 // upon destruction of the assembler. 575 // upon destruction of the assembler.
538 Assembler(void* buffer, int buffer_size); 576 // TODO(vitalyr): the assembler does not need an isolate.
577 Assembler(Isolate* isolate, void* buffer, int buffer_size);
539 ~Assembler(); 578 ~Assembler();
540 579
541 // Overrides the default provided by FLAG_debug_code. 580 // Overrides the default provided by FLAG_debug_code.
542 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } 581 void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
543 582
544 // GetCode emits any pending (non-emitted) code and fills the descriptor 583 // GetCode emits any pending (non-emitted) code and fills the descriptor
545 // desc. GetCode() is idempotent; it returns the same result if no other 584 // desc. GetCode() is idempotent; it returns the same result if no other
546 // Assembler functions are invoked in between GetCode() calls. 585 // Assembler functions are invoked in between GetCode() calls.
547 void GetCode(CodeDesc* desc); 586 void GetCode(CodeDesc* desc);
548 587
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 private: 1150 private:
1112 Assembler* assembler_; 1151 Assembler* assembler_;
1113 #ifdef DEBUG 1152 #ifdef DEBUG
1114 int space_before_; 1153 int space_before_;
1115 #endif 1154 #endif
1116 }; 1155 };
1117 1156
1118 } } // namespace v8::internal 1157 } } // namespace v8::internal
1119 1158
1120 #endif // V8_IA32_ASSEMBLER_IA32_H_ 1159 #endif // V8_IA32_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698