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

Side by Side Diff: runtime/vm/assembler_x64.cc

Issue 142663004: Reverts refactoring of CPU feature detection for (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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 | « runtime/vm/assembler_x64.h ('k') | runtime/vm/cpu.h » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h"
10 #include "vm/heap.h" 9 #include "vm/heap.h"
11 #include "vm/memory_region.h" 10 #include "vm/memory_region.h"
12 #include "vm/runtime_entry.h" 11 #include "vm/runtime_entry.h"
13 #include "vm/stack_frame.h" 12 #include "vm/stack_frame.h"
14 #include "vm/stub_code.h" 13 #include "vm/stub_code.h"
15 14
16 namespace dart { 15 namespace dart {
17 16
18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); 17 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
18 DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available");
19 DECLARE_FLAG(bool, inline_alloc); 19 DECLARE_FLAG(bool, inline_alloc);
20 20
21 21
22 bool CPUFeatures::sse4_1_supported_ = false;
23 #ifdef DEBUG
24 bool CPUFeatures::initialized_ = false;
25 #endif
26
27 bool CPUFeatures::sse4_1_supported() {
28 DEBUG_ASSERT(initialized_);
29 return sse4_1_supported_ && FLAG_use_sse41;
30 }
31
32
33 #define __ assembler.
34
35 void CPUFeatures::InitOnce() {
36 Assembler assembler;
37 __ pushq(RBP);
38 __ pushq(RBX);
39 __ movq(RBP, RSP);
40 // Get feature information in ECX:EDX and return it in RAX.
41 // Note that cpuid operates the same in 64-bit and 32-bit mode.
42 __ movq(RAX, Immediate(1));
43 __ cpuid();
44 __ movl(RAX, RCX); // Zero extended.
45 __ shlq(RAX, Immediate(32));
46 __ movl(RCX, RDX); // Zero extended.
47 __ orq(RAX, RCX);
48 __ movq(RSP, RBP);
49 __ popq(RBX);
50 __ popq(RBP);
51 __ ret();
52
53 const Code& code =
54 Code::Handle(Code::FinalizeCode("DetectCPUFeatures", &assembler));
55 Instructions& instructions = Instructions::Handle(code.instructions());
56 typedef uint64_t (*DetectCPUFeatures)();
57 uint64_t features =
58 reinterpret_cast<DetectCPUFeatures>(instructions.EntryPoint())();
59 sse4_1_supported_ = (features & kSSE4_1BitMask) != 0;
60 #ifdef DEBUG
61 initialized_ = true;
62 #endif
63 }
64
65 #undef __
66
67
22 Assembler::Assembler(bool use_far_branches) 68 Assembler::Assembler(bool use_far_branches)
23 : buffer_(), 69 : buffer_(),
24 object_pool_(GrowableObjectArray::Handle()), 70 object_pool_(GrowableObjectArray::Handle()),
25 patchable_pool_entries_(), 71 patchable_pool_entries_(),
26 prologue_offset_(-1), 72 prologue_offset_(-1),
27 comments_() { 73 comments_() {
28 // Far branching mode is only needed and implemented for MIPS and ARM. 74 // Far branching mode is only needed and implemented for MIPS and ARM.
29 ASSERT(!use_far_branches); 75 ASSERT(!use_far_branches);
30 if (Isolate::Current() != Dart::vm_isolate()) { 76 if (Isolate::Current() != Dart::vm_isolate()) {
31 object_pool_ = GrowableObjectArray::New(Heap::kOld); 77 object_pool_ = GrowableObjectArray::New(Heap::kOld);
(...skipping 3220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 3298
3253 3299
3254 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3300 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3255 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3301 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3256 return xmm_reg_names[reg]; 3302 return xmm_reg_names[reg];
3257 } 3303 }
3258 3304
3259 } // namespace dart 3305 } // namespace dart
3260 3306
3261 #endif // defined TARGET_ARCH_X64 3307 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/cpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698