js/src/jit/AsmJSLink.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit/AsmJSLink.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99:
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef jit_AsmJSLink_h
    1.11 +#define jit_AsmJSLink_h
    1.12 +
    1.13 +#include "NamespaceImports.h"
    1.14 +
    1.15 +class JSAtom;
    1.16 +
    1.17 +namespace js {
    1.18 +
    1.19 +class AsmJSActivation;
    1.20 +class AsmJSModule;
    1.21 +namespace jit { class CallSite; }
    1.22 +
    1.23 +// Iterates over the frames of a single AsmJSActivation.
    1.24 +class AsmJSFrameIterator
    1.25 +{
    1.26 +    const AsmJSModule *module_;
    1.27 +    const jit::CallSite *callsite_;
    1.28 +    uint8_t *sp_;
    1.29 +    uint8_t *returnAddress_;
    1.30 +
    1.31 +    void popFrame();
    1.32 +    void settle();
    1.33 +
    1.34 +  public:
    1.35 +    AsmJSFrameIterator(const AsmJSActivation *activation);
    1.36 +    void operator++() { popFrame(); settle(); }
    1.37 +    bool done() const { return !callsite_; }
    1.38 +    JSAtom *functionDisplayAtom() const;
    1.39 +    unsigned computeLine(uint32_t *column) const;
    1.40 +};
    1.41 +
    1.42 +#ifdef JS_ION
    1.43 +
    1.44 +// Create a new JSFunction to replace originalFun as the representation of the
    1.45 +// function defining the succesfully-validated module 'moduleObj'.
    1.46 +extern JSFunction *
    1.47 +NewAsmJSModuleFunction(ExclusiveContext *cx, JSFunction *originalFun, HandleObject moduleObj);
    1.48 +
    1.49 +// Return whether this is the js::Native returned by NewAsmJSModuleFunction.
    1.50 +extern bool
    1.51 +IsAsmJSModuleNative(JSNative native);
    1.52 +
    1.53 +// Return whether the given value is a function containing "use asm" that has
    1.54 +// been validated according to the asm.js spec.
    1.55 +extern bool
    1.56 +IsAsmJSModule(JSContext *cx, unsigned argc, JS::Value *vp);
    1.57 +extern bool
    1.58 +IsAsmJSModule(HandleFunction fun);
    1.59 +
    1.60 +extern JSString*
    1.61 +AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda);
    1.62 +
    1.63 +// Return whether the given value is a function containing "use asm" that was
    1.64 +// loaded directly from the cache (and hence was validated previously).
    1.65 +extern bool
    1.66 +IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp);
    1.67 +
    1.68 +// Return whether the given value is a nested function in an asm.js module that
    1.69 +// has been both compile- and link-time validated.
    1.70 +extern bool
    1.71 +IsAsmJSFunction(JSContext *cx, unsigned argc, JS::Value *vp);
    1.72 +extern bool
    1.73 +IsAsmJSFunction(HandleFunction fun);
    1.74 +
    1.75 +extern JSString *
    1.76 +AsmJSFunctionToString(JSContext *cx, HandleFunction fun);
    1.77 +
    1.78 +#else // JS_ION
    1.79 +
    1.80 +inline bool
    1.81 +IsAsmJSModuleNative(JSNative native)
    1.82 +{
    1.83 +    return false;
    1.84 +}
    1.85 +
    1.86 +inline bool
    1.87 +IsAsmJSFunction(JSContext *cx, unsigned argc, Value *vp)
    1.88 +{
    1.89 +    CallArgs args = CallArgsFromVp(argc, vp);
    1.90 +    args.rval().set(BooleanValue(false));
    1.91 +    return true;
    1.92 +}
    1.93 +
    1.94 +inline bool
    1.95 +IsAsmJSFunction(HandleFunction fun)
    1.96 +{
    1.97 +    return false;
    1.98 +}
    1.99 +
   1.100 +inline JSString *
   1.101 +AsmJSFunctionToString(JSContext *cx, HandleFunction fun)
   1.102 +{
   1.103 +    return nullptr;
   1.104 +}
   1.105 +
   1.106 +inline bool
   1.107 +IsAsmJSModule(JSContext *cx, unsigned argc, Value *vp)
   1.108 +{
   1.109 +    CallArgs args = CallArgsFromVp(argc, vp);
   1.110 +    args.rval().set(BooleanValue(false));
   1.111 +    return true;
   1.112 +}
   1.113 +
   1.114 +inline bool
   1.115 +IsAsmJSModule(HandleFunction fun)
   1.116 +{
   1.117 +    return false;
   1.118 +}
   1.119 +
   1.120 +inline JSString*
   1.121 +AsmJSModuleToString(JSContext *cx, HandleFunction fun, bool addParenToLambda)
   1.122 +{
   1.123 +    return nullptr;
   1.124 +}
   1.125 +
   1.126 +inline bool
   1.127 +IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp)
   1.128 +{
   1.129 +    CallArgs args = CallArgsFromVp(argc, vp);
   1.130 +    args.rval().set(BooleanValue(false));
   1.131 +    return true;
   1.132 +}
   1.133 +
   1.134 +#endif // JS_ION
   1.135 +
   1.136 +} // namespace js
   1.137 +
   1.138 +#endif // jit_AsmJS_h

mercurial