Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are 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 23 matching lines...) Expand all Loading... | |
| 34 // significantly by Google Inc. | 34 // significantly by Google Inc. |
| 35 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 35 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 36 | 36 |
| 37 // A light-weight ARM Assembler | 37 // A light-weight ARM Assembler |
| 38 // Generates user mode instructions for the ARM architecture up to version 5 | 38 // Generates user mode instructions for the ARM architecture up to version 5 |
| 39 | 39 |
| 40 #ifndef V8_ARM_ASSEMBLER_ARM_H_ | 40 #ifndef V8_ARM_ASSEMBLER_ARM_H_ |
| 41 #define V8_ARM_ASSEMBLER_ARM_H_ | 41 #define V8_ARM_ASSEMBLER_ARM_H_ |
| 42 #include <stdio.h> | 42 #include <stdio.h> |
| 43 #include "assembler.h" | 43 #include "assembler.h" |
| 44 #include "serialize.h" | |
| 44 | 45 |
| 45 namespace v8 { | 46 namespace v8 { |
| 46 namespace internal { | 47 namespace internal { |
| 47 | 48 |
| 48 // CPU Registers. | 49 // CPU Registers. |
| 49 // | 50 // |
| 50 // 1) We would prefer to use an enum, but enum values are assignment- | 51 // 1) We would prefer to use an enum, but enum values are assignment- |
| 51 // compatible with int, which has caused code-generation bugs. | 52 // compatible with int, which has caused code-generation bugs. |
| 52 // | 53 // |
| 53 // 2) We would prefer to use a class instead of a struct but we don't like | 54 // 2) We would prefer to use a class instead of a struct but we don't like |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg | 421 int shift_imm_; // valid if rm_ != no_reg && rs_ == no_reg |
| 421 AddrMode am_; // bits P, U, and W | 422 AddrMode am_; // bits P, U, and W |
| 422 | 423 |
| 423 friend class Assembler; | 424 friend class Assembler; |
| 424 }; | 425 }; |
| 425 | 426 |
| 426 // CpuFeatures keeps track of which features are supported by the target CPU. | 427 // CpuFeatures keeps track of which features are supported by the target CPU. |
| 427 // Supported features must be enabled by a Scope before use. | 428 // Supported features must be enabled by a Scope before use. |
| 428 class CpuFeatures : public AllStatic { | 429 class CpuFeatures : public AllStatic { |
| 429 public: | 430 public: |
| 430 enum Feature { VFP3 = 1 }; | |
| 431 // Detect features of the target CPU. Set safe defaults if the serializer | 431 // Detect features of the target CPU. Set safe defaults if the serializer |
| 432 // is enabled (snapshots must be portable). | 432 // is enabled (snapshots must be portable). |
| 433 static void Probe(); | 433 static void Probe(); |
| 434 | |
| 434 // Check whether a feature is supported by the target CPU. | 435 // Check whether a feature is supported by the target CPU. |
| 435 static bool IsSupported(Feature f) { | 436 static bool IsSupported(CpuFeature f) { |
| 436 if (f == VFP3 && !FLAG_enable_vfp3) return false; | 437 if (f == VFP3 && !FLAG_enable_vfp3) return false; |
| 437 | |
| 438 return (supported_ & (1u << f)) != 0; | 438 return (supported_ & (1u << f)) != 0; |
| 439 } | 439 } |
| 440 | |
| 440 // Check whether a feature is currently enabled. | 441 // Check whether a feature is currently enabled. |
| 441 static bool IsEnabled(Feature f) { | 442 static bool IsEnabled(CpuFeature f) { |
| 442 return (enabled_ & (1u << f)) != 0; | 443 return (enabled_ & (1u << f)) != 0; |
| 443 } | 444 } |
| 445 | |
| 444 // Enable a specified feature within a scope. | 446 // Enable a specified feature within a scope. |
| 445 class Scope BASE_EMBEDDED { | 447 class Scope BASE_EMBEDDED { |
| 446 #ifdef DEBUG | 448 #ifdef DEBUG |
| 447 public: | 449 public: |
| 448 explicit Scope(Feature f) { | 450 explicit Scope(CpuFeature f) { |
| 449 ASSERT(CpuFeatures::IsSupported(f)); | 451 ASSERT(CpuFeatures::IsSupported(f)); |
| 452 ASSERT(!Serializer::enabled() || (found_by_runtime_probing_ & (1u << f)) = = 0); | |
|
Mads Ager (chromium)
2009/11/13 12:28:35
With lines this long I wonder if it lints? ;-)
| |
| 450 old_enabled_ = CpuFeatures::enabled_; | 453 old_enabled_ = CpuFeatures::enabled_; |
| 451 CpuFeatures::enabled_ |= 1u << f; | 454 CpuFeatures::enabled_ |= 1u << f; |
| 452 } | 455 } |
| 453 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } | 456 ~Scope() { CpuFeatures::enabled_ = old_enabled_; } |
| 454 private: | 457 private: |
| 455 unsigned old_enabled_; | 458 unsigned old_enabled_; |
| 456 #else | 459 #else |
| 457 public: | 460 public: |
| 458 explicit Scope(Feature f) {} | 461 explicit Scope(CpuFeature f) {} |
| 459 #endif | 462 #endif |
| 460 }; | 463 }; |
| 461 | 464 |
| 462 private: | 465 private: |
| 463 static unsigned supported_; | 466 static unsigned supported_; |
| 464 static unsigned enabled_; | 467 static unsigned enabled_; |
| 468 static unsigned found_by_runtime_probing_; | |
| 465 }; | 469 }; |
| 466 | 470 |
| 467 | 471 |
| 468 typedef int32_t Instr; | 472 typedef int32_t Instr; |
| 469 | 473 |
| 470 | 474 |
| 471 extern const Instr kMovLrPc; | 475 extern const Instr kMovLrPc; |
| 472 extern const Instr kLdrPCPattern; | 476 extern const Instr kLdrPCPattern; |
| 473 | 477 |
| 474 | 478 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 985 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 989 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
| 986 | 990 |
| 987 friend class RegExpMacroAssemblerARM; | 991 friend class RegExpMacroAssemblerARM; |
| 988 friend class RelocInfo; | 992 friend class RelocInfo; |
| 989 friend class CodePatcher; | 993 friend class CodePatcher; |
| 990 }; | 994 }; |
| 991 | 995 |
| 992 } } // namespace v8::internal | 996 } } // namespace v8::internal |
| 993 | 997 |
| 994 #endif // V8_ARM_ASSEMBLER_ARM_H_ | 998 #endif // V8_ARM_ASSEMBLER_ARM_H_ |
| OLD | NEW |