Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 #ifndef jit_AsmJSLink_h
8 #define jit_AsmJSLink_h
10 #include "NamespaceImports.h"
12 class JSAtom;
14 namespace js {
16 class AsmJSActivation;
17 class AsmJSModule;
18 namespace jit { class CallSite; }
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_;
28 void popFrame();
29 void settle();
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 };
39 #ifdef JS_ION
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);
46 // Return whether this is the js::Native returned by NewAsmJSModuleFunction.
47 extern bool
48 IsAsmJSModuleNative(JSNative native);
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);
57 extern JSString*
58 AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda);
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);
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);
72 extern JSString *
73 AsmJSFunctionToString(JSContext *cx, HandleFunction fun);
75 #else // JS_ION
77 inline bool
78 IsAsmJSModuleNative(JSNative native)
79 {
80 return false;
81 }
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 }
91 inline bool
92 IsAsmJSFunction(HandleFunction fun)
93 {
94 return false;
95 }
97 inline JSString *
98 AsmJSFunctionToString(JSContext *cx, HandleFunction fun)
99 {
100 return nullptr;
101 }
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 }
111 inline bool
112 IsAsmJSModule(HandleFunction fun)
113 {
114 return false;
115 }
117 inline JSString*
118 AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda)
119 {
120 return nullptr;
121 }
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 }
131 #endif // JS_ION
133 } // namespace js
135 #endif // jit_AsmJS_h