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/ia32/assembler-ia32.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/heap-profiler.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 19 matching lines...) Expand all
30 30
31 // The original source code covered by the above license above has been 31 // The original source code covered by the above license above has been
32 // modified significantly by Google Inc. 32 // modified significantly by Google Inc.
33 // Copyright 2011 the V8 project authors. All rights reserved. 33 // Copyright 2011 the V8 project authors. All rights reserved.
34 34
35 // A light-weight IA32 Assembler. 35 // A light-weight IA32 Assembler.
36 36
37 #ifndef V8_IA32_ASSEMBLER_IA32_H_ 37 #ifndef V8_IA32_ASSEMBLER_IA32_H_
38 #define V8_IA32_ASSEMBLER_IA32_H_ 38 #define V8_IA32_ASSEMBLER_IA32_H_
39 39
40 #include "isolate.h"
40 #include "serialize.h" 41 #include "serialize.h"
41 42
42 namespace v8 { 43 namespace v8 {
43 namespace internal { 44 namespace internal {
44 45
45 // CPU Registers. 46 // CPU Registers.
46 // 47 //
47 // 1) We would prefer to use an enum, but enum values are assignment- 48 // 1) We would prefer to use an enum, but enum values are assignment-
48 // compatible with int, which has caused code-generation bugs. 49 // compatible with int, which has caused code-generation bugs.
49 // 50 //
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 439
439 // 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.
440 // Supported features must be enabled by a Scope before use. 441 // Supported features must be enabled by a Scope before use.
441 // Example: 442 // Example:
442 // if (CpuFeatures::IsSupported(SSE2)) { 443 // if (CpuFeatures::IsSupported(SSE2)) {
443 // CpuFeatures::Scope fscope(SSE2); 444 // CpuFeatures::Scope fscope(SSE2);
444 // // Generate SSE2 floating point code. 445 // // Generate SSE2 floating point code.
445 // } else { 446 // } else {
446 // // Generate standard x87 floating point code. 447 // // Generate standard x87 floating point code.
447 // } 448 // }
448 class CpuFeatures : public AllStatic { 449 class CpuFeatures {
449 public: 450 public:
450 // Detect features of the target CPU. If the portable flag is set, 451 // Detect features of the target CPU. If the portable flag is set,
451 // the method sets safe defaults if the serializer is enabled 452 // the method sets safe defaults if the serializer is enabled
452 // (snapshots must be portable). 453 // (snapshots must be portable).
453 static void Probe(bool portable); 454 void Probe(bool portable);
454 static void Clear() { supported_ = 0; } 455 void Clear() { supported_ = 0; }
455 456
456 // Check whether a feature is supported by the target CPU. 457 // Check whether a feature is supported by the target CPU.
457 static bool IsSupported(CpuFeature f) { 458 bool IsSupported(CpuFeature f) const {
458 if (f == SSE2 && !FLAG_enable_sse2) return false; 459 if (f == SSE2 && !FLAG_enable_sse2) return false;
459 if (f == SSE3 && !FLAG_enable_sse3) return false; 460 if (f == SSE3 && !FLAG_enable_sse3) return false;
460 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false; 461 if (f == SSE4_1 && !FLAG_enable_sse4_1) return false;
461 if (f == CMOV && !FLAG_enable_cmov) return false; 462 if (f == CMOV && !FLAG_enable_cmov) return false;
462 if (f == RDTSC && !FLAG_enable_rdtsc) return false; 463 if (f == RDTSC && !FLAG_enable_rdtsc) return false;
463 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0; 464 return (supported_ & (static_cast<uint64_t>(1) << f)) != 0;
464 } 465 }
465 // Check whether a feature is currently enabled. 466 // Check whether a feature is currently enabled.
466 static bool IsEnabled(CpuFeature f) { 467 bool IsEnabled(CpuFeature f) const {
467 return (enabled_ & (static_cast<uint64_t>(1) << f)) != 0; 468 return (enabled_ & (static_cast<uint64_t>(1) << f)) != 0;
468 } 469 }
469 // Enable a specified feature within a scope. 470 // Enable a specified feature within a scope.
470 class Scope BASE_EMBEDDED { 471 class Scope BASE_EMBEDDED {
471 #ifdef DEBUG 472 #ifdef DEBUG
472 public: 473 public:
473 explicit Scope(CpuFeature f) { 474 explicit Scope(CpuFeature f)
475 : cpu_features_(Isolate::Current()->cpu_features()),
476 isolate_(Isolate::Current()) {
474 uint64_t mask = static_cast<uint64_t>(1) << f; 477 uint64_t mask = static_cast<uint64_t>(1) << f;
475 ASSERT(CpuFeatures::IsSupported(f)); 478 ASSERT(cpu_features_->IsSupported(f));
476 ASSERT(!Serializer::enabled() || (found_by_runtime_probing_ & mask) == 0); 479 ASSERT(!Serializer::enabled() ||
477 old_enabled_ = CpuFeatures::enabled_; 480 (cpu_features_->found_by_runtime_probing_ & mask) == 0);
478 CpuFeatures::enabled_ |= mask; 481 old_enabled_ = cpu_features_->enabled_;
482 cpu_features_->enabled_ |= mask;
479 } 483 }
480 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } 484 ~Scope() {
485 ASSERT_EQ(Isolate::Current(), isolate_);
486 cpu_features_->enabled_ = old_enabled_;
487 }
481 private: 488 private:
482 uint64_t old_enabled_; 489 uint64_t old_enabled_;
490 CpuFeatures* cpu_features_;
491 Isolate* isolate_;
483 #else 492 #else
484 public: 493 public:
485 explicit Scope(CpuFeature f) {} 494 explicit Scope(CpuFeature f) {}
486 #endif 495 #endif
487 }; 496 };
497
488 private: 498 private:
489 static uint64_t supported_; 499 CpuFeatures();
490 static uint64_t enabled_; 500
491 static uint64_t found_by_runtime_probing_; 501 uint64_t supported_;
502 uint64_t enabled_;
503 uint64_t found_by_runtime_probing_;
504
505 friend class Isolate;
506
507 DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
492 }; 508 };
493 509
494 510
495 class Assembler : public Malloced { 511 class Assembler : public Malloced {
496 private: 512 private:
497 // We check before assembling an instruction that there is sufficient 513 // We check before assembling an instruction that there is sufficient
498 // space to write an instruction and its relocation information. 514 // space to write an instruction and its relocation information.
499 // The relocation writer's position must be kGap bytes above the end of 515 // The relocation writer's position must be kGap bytes above the end of
500 // the generated instructions. This leaves enough space for the 516 // the generated instructions. This leaves enough space for the
501 // longest possible ia32 instruction, 15 bytes, and the longest possible 517 // longest possible ia32 instruction, 15 bytes, and the longest possible
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 1059
1044 friend class CodePatcher; 1060 friend class CodePatcher;
1045 friend class EnsureSpace; 1061 friend class EnsureSpace;
1046 1062
1047 // Code buffer: 1063 // Code buffer:
1048 // The buffer into which code and relocation info are generated. 1064 // The buffer into which code and relocation info are generated.
1049 byte* buffer_; 1065 byte* buffer_;
1050 int buffer_size_; 1066 int buffer_size_;
1051 // True if the assembler owns the buffer, false if buffer is external. 1067 // True if the assembler owns the buffer, false if buffer is external.
1052 bool own_buffer_; 1068 bool own_buffer_;
1053 // A previously allocated buffer of kMinimalBufferSize bytes, or NULL.
1054 static byte* spare_buffer_;
1055 1069
1056 // code generation 1070 // code generation
1057 byte* pc_; // the program counter; moves forward 1071 byte* pc_; // the program counter; moves forward
1058 RelocInfoWriter reloc_info_writer; 1072 RelocInfoWriter reloc_info_writer;
1059 1073
1060 // push-pop elimination 1074 // push-pop elimination
1061 byte* last_pc_; 1075 byte* last_pc_;
1062 1076
1063 PositionsRecorder positions_recorder_; 1077 PositionsRecorder positions_recorder_;
1064 1078
(...skipping 26 matching lines...) Expand all
1091 private: 1105 private:
1092 Assembler* assembler_; 1106 Assembler* assembler_;
1093 #ifdef DEBUG 1107 #ifdef DEBUG
1094 int space_before_; 1108 int space_before_;
1095 #endif 1109 #endif
1096 }; 1110 };
1097 1111
1098 } } // namespace v8::internal 1112 } } // namespace v8::internal
1099 1113
1100 #endif // V8_IA32_ASSEMBLER_IA32_H_ 1114 #endif // V8_IA32_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/heap-profiler.cc ('k') | src/ia32/assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698