|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef jit_AsmJSLink_h |
|
8 #define jit_AsmJSLink_h |
|
9 |
|
10 #include "NamespaceImports.h" |
|
11 |
|
12 class JSAtom; |
|
13 |
|
14 namespace js { |
|
15 |
|
16 class AsmJSActivation; |
|
17 class AsmJSModule; |
|
18 namespace jit { class CallSite; } |
|
19 |
|
20 // Iterates over the frames of a single AsmJSActivation. |
|
21 class AsmJSFrameIterator |
|
22 { |
|
23 const AsmJSModule *module_; |
|
24 const jit::CallSite *callsite_; |
|
25 uint8_t *sp_; |
|
26 uint8_t *returnAddress_; |
|
27 |
|
28 void popFrame(); |
|
29 void settle(); |
|
30 |
|
31 public: |
|
32 AsmJSFrameIterator(const AsmJSActivation *activation); |
|
33 void operator++() { popFrame(); settle(); } |
|
34 bool done() const { return !callsite_; } |
|
35 JSAtom *functionDisplayAtom() const; |
|
36 unsigned computeLine(uint32_t *column) const; |
|
37 }; |
|
38 |
|
39 #ifdef JS_ION |
|
40 |
|
41 // Create a new JSFunction to replace originalFun as the representation of the |
|
42 // function defining the succesfully-validated module 'moduleObj'. |
|
43 extern JSFunction * |
|
44 NewAsmJSModuleFunction(ExclusiveContext *cx, JSFunction *originalFun, HandleObject moduleObj); |
|
45 |
|
46 // Return whether this is the js::Native returned by NewAsmJSModuleFunction. |
|
47 extern bool |
|
48 IsAsmJSModuleNative(JSNative native); |
|
49 |
|
50 // Return whether the given value is a function containing "use asm" that has |
|
51 // been validated according to the asm.js spec. |
|
52 extern bool |
|
53 IsAsmJSModule(JSContext *cx, unsigned argc, JS::Value *vp); |
|
54 extern bool |
|
55 IsAsmJSModule(HandleFunction fun); |
|
56 |
|
57 extern JSString* |
|
58 AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda); |
|
59 |
|
60 // Return whether the given value is a function containing "use asm" that was |
|
61 // loaded directly from the cache (and hence was validated previously). |
|
62 extern bool |
|
63 IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp); |
|
64 |
|
65 // Return whether the given value is a nested function in an asm.js module that |
|
66 // has been both compile- and link-time validated. |
|
67 extern bool |
|
68 IsAsmJSFunction(JSContext *cx, unsigned argc, JS::Value *vp); |
|
69 extern bool |
|
70 IsAsmJSFunction(HandleFunction fun); |
|
71 |
|
72 extern JSString * |
|
73 AsmJSFunctionToString(JSContext *cx, HandleFunction fun); |
|
74 |
|
75 #else // JS_ION |
|
76 |
|
77 inline bool |
|
78 IsAsmJSModuleNative(JSNative native) |
|
79 { |
|
80 return false; |
|
81 } |
|
82 |
|
83 inline bool |
|
84 IsAsmJSFunction(JSContext *cx, unsigned argc, Value *vp) |
|
85 { |
|
86 CallArgs args = CallArgsFromVp(argc, vp); |
|
87 args.rval().set(BooleanValue(false)); |
|
88 return true; |
|
89 } |
|
90 |
|
91 inline bool |
|
92 IsAsmJSFunction(HandleFunction fun) |
|
93 { |
|
94 return false; |
|
95 } |
|
96 |
|
97 inline JSString * |
|
98 AsmJSFunctionToString(JSContext *cx, HandleFunction fun) |
|
99 { |
|
100 return nullptr; |
|
101 } |
|
102 |
|
103 inline bool |
|
104 IsAsmJSModule(JSContext *cx, unsigned argc, Value *vp) |
|
105 { |
|
106 CallArgs args = CallArgsFromVp(argc, vp); |
|
107 args.rval().set(BooleanValue(false)); |
|
108 return true; |
|
109 } |
|
110 |
|
111 inline bool |
|
112 IsAsmJSModule(HandleFunction fun) |
|
113 { |
|
114 return false; |
|
115 } |
|
116 |
|
117 inline JSString* |
|
118 AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda) |
|
119 { |
|
120 return nullptr; |
|
121 } |
|
122 |
|
123 inline bool |
|
124 IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp) |
|
125 { |
|
126 CallArgs args = CallArgsFromVp(argc, vp); |
|
127 args.rval().set(BooleanValue(false)); |
|
128 return true; |
|
129 } |
|
130 |
|
131 #endif // JS_ION |
|
132 |
|
133 } // namespace js |
|
134 |
|
135 #endif // jit_AsmJS_h |