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

Side by Side Diff: src/ia32/safe-codegen-ia32.h

Issue 660077: NOT FOR COMMITTING: Add fast side-effect free floating point expressions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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/ia32/codegen-ia32.cc ('k') | src/ia32/safe-codegen-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
(Empty)
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_SAFE_CODEGEN_IA32_H_
29 #define V8_SAFE_CODEGEN_IA32_H_
30
31 #include "v8.h"
32
33 namespace v8 {
34 namespace internal {
35
36 class SafeSyntaxChecker: public AstVisitor {
37 public:
38 SafeSyntaxChecker()
39 : has_supported_syntax_(true),
40 xmm_stack_height_(0),
41 num_operations_(0),
42 has_constant_float_(false) {}
43 bool Check(Expression* expression) {
44 Visit(expression);
45 CHECK(!has_supported_syntax() || xmm_stack_height_ == 1);
46 return has_supported_syntax() &&
47 num_operations_ > 1;
48 }
49
50 private:
51 bool has_supported_syntax() { return has_supported_syntax_; }
52 static const int MAX_XMM_STACK_HEIGHT = 8;
53 // AST node visit functions.
54 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
55 AST_NODE_LIST(DECLARE_VISIT)
56 #undef DECLARE_VISIT
57
58 bool has_supported_syntax_;
59 int xmm_stack_height_;
60 int num_operations_;
61 bool has_constant_float_;
62 DISALLOW_COPY_AND_ASSIGN(SafeSyntaxChecker);
63 };
64
65
66 class SafeGenerator: public AstVisitor {
67 public:
68
69 SafeGenerator(MacroAssembler* masm,
70 JumpTarget* unsafe_target,
71 CodeGenerator* cgen,
72 Result* scratch,
73 Result* final_result)
74 : masm_(masm),
75 unsafe_target_(unsafe_target),
76 cgen_(cgen),
77 scratch_(scratch),
78 final_result_(final_result),
79 xmm_stack_height_(0) {}
80
81
82 Result Generate(Expression* expr);
83 private:
84 MacroAssembler* masm() { return masm_; }
85
86 // AST node visit functions.
87 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
88 AST_NODE_LIST(DECLARE_VISIT)
89 #undef DECLARE_VISIT
90
91 static const int kMinUnspilledXMMRegisters = 4;
92 static const int kNumXMMRegisters = 8;
93
94 MacroAssembler* masm_;
95 JumpTarget* unsafe_target_;
96 CodeGenerator* cgen_;
97 Result* scratch_;
98 Result* final_result_;
99
100 // Implement a stack from the XMM registers (keeping the top up-to-8 elements
101 // of the stack in registers).
102 // Next xmm register to use.
103 int xmm_stack_height_;
104 // Operations on the XMM "stack".
105 void PushXMM(Handle<HeapNumber> value);
106 void PushXMM(Handle<Smi> literal);
107 void PushXMM(Slot* variable);
108
109 void StoreXMM(Register heapNumber);
110 // Utility functions.
111 void FreeStackTop() {
112 ASSERT(xmm_stack_height_ > 0);
113 xmm_stack_height_--;
114 }
115
116 XMMRegister AllocateStackElement() {
117 xmm_stack_height_++;
118 return XMMStackElement(0);
119 }
120
121 XMMRegister XMMStackElement(int offset_from_top);
122
123 DISALLOW_COPY_AND_ASSIGN(SafeGenerator);
124 };
125
126
127 } } // namespace v8::internal
128
129 #endif // V8_SAFE_CODEGEN_IA32_H_
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/ia32/safe-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698