1 # HG changeset patch |
1 # HG changeset patch |
2 # Parent 58dd942011a81f3149d9bc34e808806bda099056 |
2 # Parent 831eeca7b7cfa9ae2458d9efafe168027259965f |
3 # User Landry Breuil <landry@openbsd.org> |
3 # User Landry Breuil <landry@openbsd.org> |
4 Use YARR interpreter instead of PCRE on platforms where YARR JIT is not |
4 Bug 691898 - Use YARR regexp interpreter instead of PCRE on platforms where YARR JIT is not supported r=dmandelin |
5 supported |
5 PCRE doesn't build anyway. |
6 |
6 |
7 diff --git a/js/src/Makefile.in b/js/src/Makefile.in |
7 diff --git a/js/src/Makefile.in b/js/src/Makefile.in |
8 --- a/js/src/Makefile.in |
8 --- a/js/src/Makefile.in |
9 +++ b/js/src/Makefile.in |
9 +++ b/js/src/Makefile.in |
10 @@ -335,25 +335,29 @@ CPPSRCS += checks.cc \ |
10 @@ -315,30 +315,33 @@ ifeq (mips, $(findstring mips,$(TARGET_C |
11 # END enclude sources for V8 dtoa |
11 CPPSRCS += TrampolineMIPS.cpp |
|
12 endif |
|
13 # |
|
14 # END enclude sources for the method JIT |
12 ############################################# |
15 ############################################# |
13 |
16 |
14 # For architectures without YARR JIT, PCRE is faster than the YARR |
17 endif |
15 # interpreter (bug 684559). |
18 |
16 |
19 -# For architectures without YARR JIT, PCRE is faster than the YARR |
|
20 -# interpreter (bug 684559). |
|
21 - |
17 ifeq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU))) |
22 ifeq (,$(filter arm% sparc %86 x86_64 mips%,$(TARGET_CPU))) |
18 |
23 |
19 -VPATH += $(srcdir)/yarr/pcre \ |
24 -VPATH += $(srcdir)/yarr/pcre \ |
20 +VPATH += $(srcdir)/assembler \ |
25 +VPATH += $(srcdir)/assembler \ |
21 + $(srcdir)/assembler/wtf \ |
26 + $(srcdir)/assembler/wtf \ |
22 + $(srcdir)/yarr \ |
27 + $(srcdir)/assembler/jit \ |
|
28 + $(srcdir)/yarr \ |
23 $(NULL) |
29 $(NULL) |
24 |
30 |
25 CPPSRCS += \ |
31 -CPPSRCS += \ |
26 - pcre_compile.cpp \ |
32 - pcre_compile.cpp \ |
27 - pcre_exec.cpp \ |
33 - pcre_exec.cpp \ |
28 - pcre_tables.cpp \ |
34 - pcre_tables.cpp \ |
29 - pcre_xclass.cpp \ |
35 - pcre_xclass.cpp \ |
30 - pcre_ucp_searchfuncs.cpp \ |
36 - pcre_ucp_searchfuncs.cpp \ |
31 + OSAllocatorOS2.cpp \ |
37 +CPPSRCS += ExecutableAllocator.cpp \ |
32 + OSAllocatorPosix.cpp \ |
38 + ExecutableAllocatorPosix.cpp \ |
33 + OSAllocatorWin.cpp \ |
39 + OSAllocatorOS2.cpp \ |
34 + PageBlock.cpp \ |
40 + OSAllocatorPosix.cpp \ |
35 + YarrInterpreter.cpp \ |
41 + OSAllocatorWin.cpp \ |
36 + YarrPattern.cpp \ |
42 + PageBlock.cpp \ |
37 + YarrSyntaxChecker.cpp \ |
43 + YarrInterpreter.cpp \ |
|
44 + YarrPattern.cpp \ |
|
45 + YarrSyntaxChecker.cpp \ |
38 $(NULL) |
46 $(NULL) |
39 else |
47 else |
40 |
48 |
41 ############################################### |
49 ############################################### |
42 # BEGIN include sources for the Nitro assembler |
50 # BEGIN include sources for the Nitro assembler |
43 # |
51 # |
44 |
52 |
45 ENABLE_YARR_JIT = 1 |
53 ENABLE_YARR_JIT = 1 |
46 @@ -878,20 +882,20 @@ endif |
54 diff --git a/js/src/assembler/jit/ExecutableAllocator.h b/js/src/assembler/jit/ExecutableAllocator.h |
47 |
55 --- a/js/src/assembler/jit/ExecutableAllocator.h |
48 ############################################### |
56 +++ b/js/src/assembler/jit/ExecutableAllocator.h |
49 # BEGIN kludges for the Nitro assembler |
57 @@ -462,18 +462,16 @@ public: |
50 # |
58 : "r" (code), "r" (reinterpret_cast<char*>(code) + size) |
51 |
59 : "r0", "r1", "r2"); |
52 # Needed to "configure" it correctly. Unfortunately these |
60 } |
53 # flags wind up being applied to all code in js/src, not just |
61 #elif WTF_CPU_SPARC |
54 # the code in js/src/assembler. |
62 static void cacheFlush(void* code, size_t size) |
55 -CXXFLAGS += -DUSE_SYSTEM_MALLOC=1 -DENABLE_ASSEMBLER=1 |
63 { |
56 +CXXFLAGS += -DUSE_SYSTEM_MALLOC=1 |
64 sync_instruction_memory((caddr_t)code, size); |
57 |
65 } |
58 ifneq (,$(ENABLE_YARR_JIT)$(ENABLE_METHODJIT)) |
66 -#else |
59 -CXXFLAGS += -DENABLE_JIT=1 |
67 - #error "The cacheFlush support is missing on this platform." |
60 +CXXFLAGS += -DENABLE_JIT=1 -DENABLE_ASSEMBLER=1 |
68 #endif |
61 endif |
69 |
62 |
70 private: |
63 INCLUDES += -I$(srcdir)/assembler -I$(srcdir)/yarr |
71 |
64 |
72 #if ENABLE_ASSEMBLER_WX_EXCLUSIVE |
65 ifdef ENABLE_METHODJIT |
73 static void reprotectRegion(void*, size_t, ProtectionSetting); |
66 # Build a standalone test program that exercises the assembler |
74 #endif |
67 # sources a bit. |
|
68 TESTMAIN_OBJS = \ |
|
69 diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp |
|
70 --- a/js/src/jsapi.cpp |
|
71 +++ b/js/src/jsapi.cpp |
|
72 @@ -696,17 +696,19 @@ JS_IsBuiltinFunctionConstructor(JSFuncti |
|
73 static JSBool js_NewRuntimeWasCalled = JS_FALSE; |
|
74 |
|
75 JSRuntime::JSRuntime() |
|
76 : atomsCompartment(NULL), |
|
77 #ifdef JS_THREADSAFE |
|
78 ownerThread_(NULL), |
|
79 #endif |
|
80 tempLifoAlloc(TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE), |
|
81 +#if ENABLE_ASSEMBLER |
|
82 execAlloc_(NULL), |
|
83 +#endif |
|
84 bumpAlloc_(NULL), |
|
85 nativeStackBase(0), |
|
86 nativeStackQuota(0), |
|
87 interpreterFrames(NULL), |
|
88 cxCallback(NULL), |
|
89 compartmentCallback(NULL), |
|
90 activityCallback(NULL), |
|
91 activityCallbackArg(NULL), |
|
92 @@ -851,17 +853,19 @@ JSRuntime::init(uint32_t maxbytes) |
|
93 nativeStackBase = GetNativeStackBase(); |
|
94 return true; |
|
95 } |
|
96 |
|
97 JSRuntime::~JSRuntime() |
|
98 { |
|
99 JS_ASSERT(onOwnerThread()); |
|
100 |
|
101 +#if ENABLE_ASSEMBLER |
|
102 delete_<JSC::ExecutableAllocator>(execAlloc_); |
|
103 +#endif |
|
104 delete_<WTF::BumpPointerAllocator>(bumpAlloc_); |
|
105 |
|
106 #ifdef DEBUG |
|
107 /* Don't hurt everyone in leaky ol' Mozilla with a fatal JS_ASSERT! */ |
|
108 if (!JS_CLIST_IS_EMPTY(&contextList)) { |
|
109 JSContext *cx, *iter = NULL; |
|
110 uintN cxcount = 0; |
|
111 while ((cx = js_ContextIterator(this, JS_TRUE, &iter)) != NULL) { |
|
112 diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp |
|
113 --- a/js/src/jscntxt.cpp |
|
114 +++ b/js/src/jscntxt.cpp |
|
115 @@ -100,19 +100,21 @@ JSRuntime::sizeOfExcludingThis(JSMallocS |
|
116 if (normal) |
|
117 *normal = mallocSizeOf(dtoaState); |
|
118 |
|
119 if (temporary) |
|
120 *temporary = tempLifoAlloc.sizeOfExcludingThis(mallocSizeOf); |
|
121 |
|
122 if (regexpCode) { |
|
123 size_t method = 0, regexp = 0, unused = 0; |
|
124 +#if ENABLE_ASSEMBLER |
|
125 if (execAlloc_) |
|
126 execAlloc_->sizeOfCode(&method, ®exp, &unused); |
|
127 JS_ASSERT(method == 0); /* this execAlloc is only used for regexp code */ |
|
128 +#endif |
|
129 *regexpCode = regexp + unused; |
|
130 } |
|
131 |
|
132 if (stackCommitted) |
|
133 *stackCommitted = stackSpace.sizeOfCommitted(); |
|
134 } |
|
135 |
|
136 JS_FRIEND_API(void) |
|
137 @@ -124,33 +126,37 @@ JSRuntime::triggerOperationCallback() |
|
138 */ |
|
139 JS_ATOMIC_SET(&interrupt, 1); |
|
140 } |
|
141 |
|
142 void |
|
143 JSRuntime::setJitHardening(bool enabled) |
|
144 { |
|
145 jitHardening = enabled; |
|
146 +#if ENABLE_ASSEMBLER |
|
147 if (execAlloc_) |
|
148 execAlloc_->setRandomize(enabled); |
|
149 +#endif |
|
150 } |
|
151 |
|
152 +#if ENABLE_ASSEMBLER |
|
153 JSC::ExecutableAllocator * |
|
154 JSRuntime::createExecutableAllocator(JSContext *cx) |
|
155 { |
|
156 JS_ASSERT(!execAlloc_); |
|
157 JS_ASSERT(cx->runtime == this); |
|
158 |
|
159 JSC::AllocationBehavior randomize = |
|
160 jitHardening ? JSC::AllocationCanRandomize : JSC::AllocationDeterministic; |
|
161 execAlloc_ = new_<JSC::ExecutableAllocator>(randomize); |
|
162 if (!execAlloc_) |
|
163 js_ReportOutOfMemory(cx); |
|
164 return execAlloc_; |
|
165 } |
|
166 +#endif |
|
167 |
|
168 WTF::BumpPointerAllocator * |
|
169 JSRuntime::createBumpPointerAllocator(JSContext *cx) |
|
170 { |
|
171 JS_ASSERT(!bumpAlloc_); |
|
172 JS_ASSERT(cx->runtime == this); |
|
173 |
|
174 bumpAlloc_ = new_<WTF::BumpPointerAllocator>(); |
|
175 diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h |
|
176 --- a/js/src/jscntxt.h |
|
177 +++ b/js/src/jscntxt.h |
|
178 @@ -219,26 +219,32 @@ struct JSRuntime : js::RuntimeFriendFiel |
|
179 static const size_t TEMP_LIFO_ALLOC_PRIMARY_CHUNK_SIZE = 1 << 12; |
|
180 js::LifoAlloc tempLifoAlloc; |
|
181 |
|
182 private: |
|
183 /* |
|
184 * Both of these allocators are used for regular expression code which is shared at the |
|
185 * thread-data level. |
|
186 */ |
|
187 +#if ENABLE_ASSEMBLER |
|
188 JSC::ExecutableAllocator *execAlloc_; |
|
189 +#endif |
|
190 WTF::BumpPointerAllocator *bumpAlloc_; |
|
191 |
|
192 +#if ENABLE_ASSEMBLER |
|
193 JSC::ExecutableAllocator *createExecutableAllocator(JSContext *cx); |
|
194 +#endif |
|
195 WTF::BumpPointerAllocator *createBumpPointerAllocator(JSContext *cx); |
|
196 |
|
197 public: |
|
198 +#if ENABLE_ASSEMBLER |
|
199 JSC::ExecutableAllocator *getExecutableAllocator(JSContext *cx) { |
|
200 return execAlloc_ ? execAlloc_ : createExecutableAllocator(cx); |
|
201 } |
|
202 +#endif |
|
203 WTF::BumpPointerAllocator *getBumpPointerAllocator(JSContext *cx) { |
|
204 return bumpAlloc_ ? bumpAlloc_ : createBumpPointerAllocator(cx); |
|
205 } |
|
206 |
|
207 /* Base address of the native stack for the current thread. */ |
|
208 uintptr_t nativeStackBase; |
|
209 |
|
210 /* The native stack size limit that runtime should not exceed. */ |
|
211 diff --git a/js/src/jsprvtd.h b/js/src/jsprvtd.h |
|
212 --- a/js/src/jsprvtd.h |
|
213 +++ b/js/src/jsprvtd.h |
|
214 @@ -313,22 +313,23 @@ typedef Handle<BaseShape*> Handl |
|
215 typedef Handle<types::TypeObject*> HandleTypeObject; |
|
216 typedef Handle<JSString*> HandleString; |
|
217 typedef Handle<JSAtom*> HandleAtom; |
|
218 typedef Handle<jsid> HandleId; |
|
219 typedef Handle<Value> HandleValue; |
|
220 |
|
221 } /* namespace js */ |
|
222 |
|
223 +#if ENABLE_ASSEMBLER |
|
224 namespace JSC { |
|
225 |
|
226 class ExecutableAllocator; |
|
227 |
|
228 } /* namespace JSC */ |
|
229 - |
|
230 +#endif |
|
231 namespace WTF { |
|
232 |
|
233 class BumpPointerAllocator; |
|
234 |
|
235 } /* namespace WTF */ |
|
236 |
|
237 } /* export "C++" */ |
|
238 |
75 |
239 diff --git a/js/src/vm/RegExpObject-inl.h b/js/src/vm/RegExpObject-inl.h |
76 diff --git a/js/src/vm/RegExpObject-inl.h b/js/src/vm/RegExpObject-inl.h |
240 --- a/js/src/vm/RegExpObject-inl.h |
77 --- a/js/src/vm/RegExpObject-inl.h |
241 +++ b/js/src/vm/RegExpObject-inl.h |
78 +++ b/js/src/vm/RegExpObject-inl.h |
242 @@ -132,26 +132,28 @@ RegExpObject::setMultiline(bool enabled) |
79 @@ -132,26 +132,28 @@ RegExpObject::setMultiline(bool enabled) |