michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_AsmJSLink_h michael@0: #define jit_AsmJSLink_h michael@0: michael@0: #include "NamespaceImports.h" michael@0: michael@0: class JSAtom; michael@0: michael@0: namespace js { michael@0: michael@0: class AsmJSActivation; michael@0: class AsmJSModule; michael@0: namespace jit { class CallSite; } michael@0: michael@0: // Iterates over the frames of a single AsmJSActivation. michael@0: class AsmJSFrameIterator michael@0: { michael@0: const AsmJSModule *module_; michael@0: const jit::CallSite *callsite_; michael@0: uint8_t *sp_; michael@0: uint8_t *returnAddress_; michael@0: michael@0: void popFrame(); michael@0: void settle(); michael@0: michael@0: public: michael@0: AsmJSFrameIterator(const AsmJSActivation *activation); michael@0: void operator++() { popFrame(); settle(); } michael@0: bool done() const { return !callsite_; } michael@0: JSAtom *functionDisplayAtom() const; michael@0: unsigned computeLine(uint32_t *column) const; michael@0: }; michael@0: michael@0: #ifdef JS_ION michael@0: michael@0: // Create a new JSFunction to replace originalFun as the representation of the michael@0: // function defining the succesfully-validated module 'moduleObj'. michael@0: extern JSFunction * michael@0: NewAsmJSModuleFunction(ExclusiveContext *cx, JSFunction *originalFun, HandleObject moduleObj); michael@0: michael@0: // Return whether this is the js::Native returned by NewAsmJSModuleFunction. michael@0: extern bool michael@0: IsAsmJSModuleNative(JSNative native); michael@0: michael@0: // Return whether the given value is a function containing "use asm" that has michael@0: // been validated according to the asm.js spec. michael@0: extern bool michael@0: IsAsmJSModule(JSContext *cx, unsigned argc, JS::Value *vp); michael@0: extern bool michael@0: IsAsmJSModule(HandleFunction fun); michael@0: michael@0: extern JSString* michael@0: AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda); michael@0: michael@0: // Return whether the given value is a function containing "use asm" that was michael@0: // loaded directly from the cache (and hence was validated previously). michael@0: extern bool michael@0: IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp); michael@0: michael@0: // Return whether the given value is a nested function in an asm.js module that michael@0: // has been both compile- and link-time validated. michael@0: extern bool michael@0: IsAsmJSFunction(JSContext *cx, unsigned argc, JS::Value *vp); michael@0: extern bool michael@0: IsAsmJSFunction(HandleFunction fun); michael@0: michael@0: extern JSString * michael@0: AsmJSFunctionToString(JSContext *cx, HandleFunction fun); michael@0: michael@0: #else // JS_ION michael@0: michael@0: inline bool michael@0: IsAsmJSModuleNative(JSNative native) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: inline bool michael@0: IsAsmJSFunction(JSContext *cx, unsigned argc, Value *vp) michael@0: { michael@0: CallArgs args = CallArgsFromVp(argc, vp); michael@0: args.rval().set(BooleanValue(false)); michael@0: return true; michael@0: } michael@0: michael@0: inline bool michael@0: IsAsmJSFunction(HandleFunction fun) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: inline JSString * michael@0: AsmJSFunctionToString(JSContext *cx, HandleFunction fun) michael@0: { michael@0: return nullptr; michael@0: } michael@0: michael@0: inline bool michael@0: IsAsmJSModule(JSContext *cx, unsigned argc, Value *vp) michael@0: { michael@0: CallArgs args = CallArgsFromVp(argc, vp); michael@0: args.rval().set(BooleanValue(false)); michael@0: return true; michael@0: } michael@0: michael@0: inline bool michael@0: IsAsmJSModule(HandleFunction fun) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: inline JSString* michael@0: AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda) michael@0: { michael@0: return nullptr; michael@0: } michael@0: michael@0: inline bool michael@0: IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp) michael@0: { michael@0: CallArgs args = CallArgsFromVp(argc, vp); michael@0: args.rval().set(BooleanValue(false)); michael@0: return true; michael@0: } michael@0: michael@0: #endif // JS_ION michael@0: michael@0: } // namespace js michael@0: michael@0: #endif // jit_AsmJS_h