2008-12-08 21:11:56 -08:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2008-07-07 02:55:03 -07:00
|
|
|
* vim: set ts=8 sw=4 et tw=99 ft=cpp:
|
2008-05-30 18:58:43 -07:00
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
|
|
|
|
* May 28, 2008.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
2008-06-28 09:58:15 -07:00
|
|
|
* Brendan Eich <brendan@mozilla.org>
|
2008-05-30 18:58:43 -07:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2008-06-28 09:58:15 -07:00
|
|
|
* Andreas Gal <gal@mozilla.com>
|
2008-07-15 15:05:16 -07:00
|
|
|
* Mike Shaver <shaver@mozilla.org>
|
|
|
|
* David Anderson <danderson@mozilla.com>
|
2008-05-30 18:58:43 -07:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2008-05-31 15:29:54 -07:00
|
|
|
#ifndef jstracer_h___
|
|
|
|
#define jstracer_h___
|
2008-05-30 18:58:43 -07:00
|
|
|
|
2008-09-11 15:53:00 -07:00
|
|
|
#ifdef JS_TRACER
|
2008-08-12 08:36:29 -07:00
|
|
|
|
2008-11-07 15:23:43 -08:00
|
|
|
#include "jscntxt.h"
|
2008-05-30 18:58:43 -07:00
|
|
|
#include "jsstddef.h"
|
2008-07-23 02:57:56 -07:00
|
|
|
#include "jstypes.h"
|
2008-05-30 18:58:43 -07:00
|
|
|
#include "jslock.h"
|
2008-07-02 14:38:12 -07:00
|
|
|
#include "jsnum.h"
|
2008-07-03 22:08:13 -07:00
|
|
|
#include "jsinterp.h"
|
2008-10-08 15:08:33 -07:00
|
|
|
#include "jsbuiltins.h"
|
2008-07-05 16:28:03 -07:00
|
|
|
|
2008-10-29 21:56:35 -07:00
|
|
|
#if defined(DEBUG) && !defined(JS_JIT_SPEW)
|
|
|
|
#define JS_JIT_SPEW
|
|
|
|
#endif
|
|
|
|
|
2008-07-29 23:48:39 -07:00
|
|
|
template <typename T>
|
2008-11-07 15:52:51 -08:00
|
|
|
class Queue : public avmplus::GCObject {
|
2008-07-29 23:48:39 -07:00
|
|
|
T* _data;
|
|
|
|
unsigned _len;
|
|
|
|
unsigned _max;
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-30 04:17:22 -07:00
|
|
|
void ensure(unsigned size) {
|
2008-11-13 00:30:20 -08:00
|
|
|
while (_max < size)
|
2008-07-30 04:17:22 -07:00
|
|
|
_max <<= 1;
|
|
|
|
_data = (T*)realloc(_data, _max * sizeof(T));
|
2009-01-21 22:45:19 -08:00
|
|
|
#if defined(DEBUG)
|
|
|
|
memset(&_data[_len], 0xcd, _max - _len);
|
|
|
|
#endif
|
2008-07-30 04:17:22 -07:00
|
|
|
}
|
2008-07-29 23:48:39 -07:00
|
|
|
public:
|
|
|
|
Queue(unsigned max = 16) {
|
|
|
|
this->_max = max;
|
|
|
|
this->_len = 0;
|
|
|
|
this->_data = (T*)malloc(max * sizeof(T));
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-29 23:48:39 -07:00
|
|
|
~Queue() {
|
|
|
|
free(_data);
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-08-06 19:06:37 -07:00
|
|
|
bool contains(T a) {
|
2009-01-10 15:25:03 -08:00
|
|
|
for (unsigned n = 0; n < _len; ++n) {
|
2008-08-06 19:06:37 -07:00
|
|
|
if (_data[n] == a)
|
|
|
|
return true;
|
2009-01-10 15:25:03 -08:00
|
|
|
}
|
2008-08-06 19:06:37 -07:00
|
|
|
return false;
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-29 23:48:39 -07:00
|
|
|
void add(T a) {
|
2008-07-30 04:17:22 -07:00
|
|
|
ensure(_len + 1);
|
2008-08-26 01:00:53 -07:00
|
|
|
JS_ASSERT(_len <= _max);
|
2008-07-29 23:48:39 -07:00
|
|
|
_data[_len++] = a;
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-08-26 01:00:53 -07:00
|
|
|
void add(T* chunk, unsigned size) {
|
|
|
|
ensure(_len + size);
|
|
|
|
JS_ASSERT(_len <= _max);
|
|
|
|
memcpy(&_data[_len], chunk, size * sizeof(T));
|
|
|
|
_len += size;
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-08-11 15:16:34 -07:00
|
|
|
void addUnique(T a) {
|
|
|
|
if (!contains(a))
|
|
|
|
add(a);
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-30 04:17:22 -07:00
|
|
|
void setLength(unsigned len) {
|
|
|
|
ensure(len + 1);
|
|
|
|
_len = len;
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-29 23:48:39 -07:00
|
|
|
void clear() {
|
|
|
|
_len = 0;
|
|
|
|
}
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-11-21 15:31:59 -08:00
|
|
|
const T & get(unsigned i) const {
|
|
|
|
return _data[i];
|
|
|
|
}
|
|
|
|
|
2008-07-29 23:48:39 -07:00
|
|
|
unsigned length() const {
|
|
|
|
return _len;
|
|
|
|
}
|
|
|
|
|
|
|
|
T* data() const {
|
|
|
|
return _data;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-06-21 14:55:32 -07:00
|
|
|
/*
|
2008-07-07 02:55:03 -07:00
|
|
|
* Tracker is used to keep track of values being manipulated by the interpreter
|
|
|
|
* during trace recording.
|
2008-06-21 14:55:32 -07:00
|
|
|
*/
|
2008-07-07 02:55:03 -07:00
|
|
|
class Tracker {
|
2008-06-21 14:55:32 -07:00
|
|
|
struct Page {
|
2008-07-05 11:18:26 -07:00
|
|
|
struct Page* next;
|
|
|
|
jsuword base;
|
2008-07-10 18:42:04 -07:00
|
|
|
nanojit::LIns* map[1];
|
2008-06-21 14:55:32 -07:00
|
|
|
};
|
|
|
|
struct Page* pagelist;
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-07-05 11:18:26 -07:00
|
|
|
jsuword getPageBase(const void* v) const;
|
2008-06-26 20:46:51 -07:00
|
|
|
struct Page* findPage(const void* v) const;
|
|
|
|
struct Page* addPage(const void* v);
|
2008-07-07 02:21:04 -07:00
|
|
|
public:
|
2008-06-21 14:55:32 -07:00
|
|
|
Tracker();
|
|
|
|
~Tracker();
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-07-20 14:23:39 -07:00
|
|
|
bool has(const void* v) const;
|
2008-07-10 18:42:04 -07:00
|
|
|
nanojit::LIns* get(const void* v) const;
|
|
|
|
void set(const void* v, nanojit::LIns* ins);
|
2008-06-26 20:44:23 -07:00
|
|
|
void clear();
|
2008-06-21 14:55:32 -07:00
|
|
|
};
|
|
|
|
|
2009-01-06 14:51:32 -08:00
|
|
|
#ifdef JS_JIT_SPEW
|
|
|
|
extern bool js_verboseDebug;
|
|
|
|
#define debug_only_v(x) if (js_verboseDebug) { x; }
|
|
|
|
#else
|
|
|
|
#define debug_only_v(x)
|
|
|
|
#endif
|
|
|
|
|
2008-08-07 15:28:43 -07:00
|
|
|
/*
|
2009-01-23 14:24:50 -08:00
|
|
|
* The oracle keeps track of hit counts for program counter locations, as
|
|
|
|
* well as slots that should not be demoted to int because we know them to
|
|
|
|
* overflow or they result in type-unstable traces. We are using simple
|
|
|
|
* hash tables. Collisions lead to loss of optimization (demotable slots
|
|
|
|
* are not demoted, etc.) but have no correctness implications.
|
2008-08-07 15:28:43 -07:00
|
|
|
*/
|
|
|
|
#define ORACLE_SIZE 4096
|
|
|
|
|
|
|
|
class Oracle {
|
2009-01-23 14:24:50 -08:00
|
|
|
uint32_t hits[ORACLE_SIZE];
|
|
|
|
uint32_t blacklistLevels[ORACLE_SIZE];
|
2008-11-24 14:53:27 -08:00
|
|
|
avmplus::BitSet _stackDontDemote;
|
|
|
|
avmplus::BitSet _globalDontDemote;
|
2008-08-07 15:28:43 -07:00
|
|
|
public:
|
2009-01-23 14:24:50 -08:00
|
|
|
Oracle();
|
|
|
|
int32_t hit(const void* ip);
|
|
|
|
int32_t getHits(const void* ip);
|
|
|
|
void resetHits(const void* ip);
|
|
|
|
void blacklist(const void* ip);
|
|
|
|
|
2009-01-07 14:14:51 -08:00
|
|
|
JS_REQUIRES_STACK void markGlobalSlotUndemotable(JSContext* cx, unsigned slot);
|
|
|
|
JS_REQUIRES_STACK bool isGlobalSlotUndemotable(JSContext* cx, unsigned slot) const;
|
|
|
|
JS_REQUIRES_STACK void markStackSlotUndemotable(JSContext* cx, unsigned slot);
|
|
|
|
JS_REQUIRES_STACK bool isStackSlotUndemotable(JSContext* cx, unsigned slot) const;
|
2009-01-23 14:24:50 -08:00
|
|
|
void clearHitCounts();
|
|
|
|
void clearDemotability();
|
|
|
|
void clear() {
|
|
|
|
clearDemotability();
|
|
|
|
clearHitCounts();
|
|
|
|
}
|
2008-08-07 15:28:43 -07:00
|
|
|
};
|
|
|
|
|
2008-08-07 17:22:21 -07:00
|
|
|
typedef Queue<uint16> SlotList;
|
|
|
|
|
2008-08-07 15:28:43 -07:00
|
|
|
class TypeMap : public Queue<uint8> {
|
|
|
|
public:
|
2009-01-21 22:45:19 -08:00
|
|
|
JS_REQUIRES_STACK void captureTypes(JSContext* cx, SlotList& slots, unsigned callDepth);
|
|
|
|
JS_REQUIRES_STACK void captureMissingGlobalTypes(JSContext* cx,
|
|
|
|
SlotList& slots,
|
|
|
|
unsigned stackSlots);
|
2008-08-19 11:32:36 -07:00
|
|
|
bool matches(TypeMap& other) const;
|
2008-08-07 15:28:43 -07:00
|
|
|
};
|
|
|
|
|
2008-11-07 15:23:43 -08:00
|
|
|
enum ExitType {
|
|
|
|
BRANCH_EXIT,
|
|
|
|
LOOP_EXIT,
|
|
|
|
NESTED_EXIT,
|
|
|
|
MISMATCH_EXIT,
|
|
|
|
OOM_EXIT,
|
|
|
|
OVERFLOW_EXIT,
|
|
|
|
UNSTABLE_LOOP_EXIT,
|
|
|
|
TIMEOUT_EXIT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VMSideExit : public nanojit::SideExit
|
|
|
|
{
|
2008-12-18 21:08:57 -08:00
|
|
|
JSObject* block;
|
2008-11-07 15:23:43 -08:00
|
|
|
intptr_t ip_adj;
|
|
|
|
intptr_t sp_adj;
|
|
|
|
intptr_t rp_adj;
|
|
|
|
int32_t calldepth;
|
|
|
|
uint32 numGlobalSlots;
|
|
|
|
uint32 numStackSlots;
|
|
|
|
uint32 numStackSlotsBelowCurrentFrame;
|
|
|
|
ExitType exitType;
|
|
|
|
};
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2009-01-21 22:45:19 -08:00
|
|
|
static inline uint8* getStackTypeMap(nanojit::SideExit* exit)
|
2008-11-07 15:23:43 -08:00
|
|
|
{
|
|
|
|
return (uint8*)(((VMSideExit*)exit) + 1);
|
|
|
|
}
|
|
|
|
|
2009-01-21 22:45:19 -08:00
|
|
|
static inline uint8* getGlobalTypeMap(nanojit::SideExit* exit)
|
|
|
|
{
|
|
|
|
return getStackTypeMap(exit) + ((VMSideExit*)exit)->numStackSlots;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint8* getFullTypeMap(nanojit::SideExit* exit)
|
|
|
|
{
|
|
|
|
return getStackTypeMap(exit);
|
|
|
|
}
|
|
|
|
|
2008-11-07 15:23:43 -08:00
|
|
|
struct InterpState
|
|
|
|
{
|
|
|
|
void* sp; /* native stack pointer, stack[0] is spbase[0] */
|
|
|
|
void* rp; /* call stack pointer */
|
|
|
|
void* gp; /* global frame pointer */
|
|
|
|
JSContext *cx; /* current VM context handle */
|
|
|
|
void* eos; /* first unusable word after the native stack */
|
|
|
|
void* eor; /* first unusable word after the call stack */
|
|
|
|
VMSideExit* lastTreeExitGuard; /* guard we exited on during a tree call */
|
|
|
|
VMSideExit* lastTreeCallGuard; /* guard we want to grow from if the tree
|
|
|
|
call exit guard mismatched */
|
|
|
|
void* rpAtLastTreeCall; /* value of rp at innermost tree call guard */
|
2009-01-25 09:04:03 -08:00
|
|
|
JSObject* globalObj; /* pointer to the global object */
|
2008-11-07 15:23:43 -08:00
|
|
|
};
|
|
|
|
|
2008-10-27 20:42:49 -07:00
|
|
|
struct UnstableExit
|
|
|
|
{
|
|
|
|
nanojit::Fragment* fragment;
|
2008-11-07 15:23:43 -08:00
|
|
|
VMSideExit* exit;
|
2008-10-27 20:42:49 -07:00
|
|
|
UnstableExit* next;
|
|
|
|
};
|
|
|
|
|
2008-08-11 16:01:21 -07:00
|
|
|
class TreeInfo MMGC_SUBCLASS_DECL {
|
2008-08-06 19:25:24 -07:00
|
|
|
nanojit::Fragment* fragment;
|
2008-07-16 21:41:03 -07:00
|
|
|
public:
|
2008-08-22 17:31:23 -07:00
|
|
|
JSScript* script;
|
2008-07-23 23:18:02 -07:00
|
|
|
unsigned maxNativeStackSlots;
|
2008-07-23 02:57:56 -07:00
|
|
|
ptrdiff_t nativeStackBase;
|
2008-07-14 19:12:50 -07:00
|
|
|
unsigned maxCallDepth;
|
2009-01-21 22:45:19 -08:00
|
|
|
TypeMap typeMap;
|
|
|
|
unsigned stackSlots;
|
2008-08-27 17:25:56 -07:00
|
|
|
Queue<nanojit::Fragment*> dependentTrees;
|
2008-09-02 23:52:11 -07:00
|
|
|
unsigned branchCount;
|
2008-11-07 15:23:43 -08:00
|
|
|
Queue<VMSideExit*> sideExits;
|
2008-10-27 20:42:49 -07:00
|
|
|
UnstableExit* unstableExits;
|
2008-08-27 17:25:56 -07:00
|
|
|
|
2008-10-27 20:42:49 -07:00
|
|
|
TreeInfo(nanojit::Fragment* _fragment) : unstableExits(NULL) {
|
2008-08-27 17:25:56 -07:00
|
|
|
fragment = _fragment;
|
2008-08-16 23:43:49 -07:00
|
|
|
}
|
2008-10-27 20:42:49 -07:00
|
|
|
~TreeInfo();
|
2009-01-21 22:45:19 -08:00
|
|
|
|
|
|
|
inline unsigned globalSlots() {
|
|
|
|
return typeMap.length() - stackSlots;
|
|
|
|
}
|
|
|
|
inline uint8* globalTypeMap() {
|
|
|
|
return typeMap.data() + stackSlots;
|
|
|
|
}
|
|
|
|
inline uint8* stackTypeMap() {
|
|
|
|
return typeMap.data();
|
|
|
|
}
|
2008-07-04 13:23:42 -07:00
|
|
|
};
|
2008-10-12 15:39:32 -07:00
|
|
|
|
|
|
|
struct FrameInfo {
|
|
|
|
JSObject* callee; // callee function object
|
2008-12-18 21:08:57 -08:00
|
|
|
JSObject* block; // caller block chain head
|
|
|
|
intptr_t ip_adj; // caller script-based pc index and imacro pc
|
2008-10-12 15:39:32 -07:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint16 spdist; // distance from fp->slots to fp->regs->sp at JSOP_CALL
|
|
|
|
uint16 argc; // actual argument count, may be < fun->nargs
|
|
|
|
} s;
|
|
|
|
uint32 word; // for spdist/argc LIR store in record_JSOP_CALL
|
|
|
|
};
|
|
|
|
};
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-12-21 03:55:09 -08:00
|
|
|
enum JSMonitorRecordingStatus {
|
|
|
|
JSMRS_CONTINUE,
|
|
|
|
JSMRS_STOP,
|
|
|
|
JSMRS_IMACRO
|
|
|
|
};
|
|
|
|
|
2008-11-07 15:52:51 -08:00
|
|
|
class TraceRecorder : public avmplus::GCObject {
|
2008-06-28 18:47:12 -07:00
|
|
|
JSContext* cx;
|
2008-08-19 11:32:36 -07:00
|
|
|
JSTraceMonitor* traceMonitor;
|
2008-07-14 16:40:38 -07:00
|
|
|
JSObject* globalObj;
|
2008-07-10 18:42:04 -07:00
|
|
|
Tracker tracker;
|
2008-07-23 23:18:02 -07:00
|
|
|
Tracker nativeFrameTracker;
|
2008-07-02 14:38:12 -07:00
|
|
|
char* entryTypeMap;
|
2008-07-21 13:18:08 -07:00
|
|
|
unsigned callDepth;
|
2008-07-10 21:55:09 -07:00
|
|
|
JSAtom** atoms;
|
2008-11-07 15:23:43 -08:00
|
|
|
VMSideExit* anchor;
|
2008-06-26 20:37:28 -07:00
|
|
|
nanojit::Fragment* fragment;
|
2008-07-21 12:41:43 -07:00
|
|
|
TreeInfo* treeInfo;
|
2008-06-27 18:06:50 -07:00
|
|
|
nanojit::LirBuffer* lirbuf;
|
2008-06-26 20:37:28 -07:00
|
|
|
nanojit::LirWriter* lir;
|
2008-07-01 19:43:10 -07:00
|
|
|
nanojit::LirBufWriter* lir_buf_writer;
|
2008-06-30 18:08:32 -07:00
|
|
|
nanojit::LirWriter* verbose_filter;
|
|
|
|
nanojit::LirWriter* cse_filter;
|
|
|
|
nanojit::LirWriter* expr_filter;
|
2008-07-05 23:21:53 -07:00
|
|
|
nanojit::LirWriter* func_filter;
|
2008-09-02 22:29:23 -07:00
|
|
|
#ifdef NJ_SOFTFLOAT
|
2008-09-02 22:29:23 -07:00
|
|
|
nanojit::LirWriter* float_filter;
|
|
|
|
#endif
|
2008-07-02 14:38:12 -07:00
|
|
|
nanojit::LIns* cx_ins;
|
2008-07-23 23:18:02 -07:00
|
|
|
nanojit::LIns* gp_ins;
|
2008-08-12 21:39:44 -07:00
|
|
|
nanojit::LIns* eos_ins;
|
2008-08-13 13:51:59 -07:00
|
|
|
nanojit::LIns* eor_ins;
|
2009-01-25 09:04:03 -08:00
|
|
|
nanojit::LIns* globalObj_ins;
|
2008-07-24 10:35:10 -07:00
|
|
|
nanojit::LIns* rval_ins;
|
2008-08-19 13:11:18 -07:00
|
|
|
nanojit::LIns* inner_sp_ins;
|
2008-08-29 18:59:21 -07:00
|
|
|
bool deepAborted;
|
2008-11-21 15:31:59 -08:00
|
|
|
bool trashSelf;
|
|
|
|
Queue<nanojit::Fragment*> whichTreesToTrash;
|
2008-08-29 15:12:17 -07:00
|
|
|
Queue<jsbytecode*> cfgMerges;
|
2008-09-23 13:29:41 -07:00
|
|
|
jsval* global_dslots;
|
2008-10-07 11:00:16 -07:00
|
|
|
JSTraceableNative* pendingTraceableNative;
|
2008-10-08 21:02:04 -07:00
|
|
|
bool terminate;
|
2008-10-27 20:42:49 -07:00
|
|
|
intptr_t terminate_ip_adj;
|
|
|
|
nanojit::Fragment* outerToBlacklist;
|
2008-11-15 16:54:24 -08:00
|
|
|
TraceRecorder* nextRecorderToAbort;
|
|
|
|
bool wasRootFragment;
|
2008-08-29 18:59:21 -07:00
|
|
|
|
2008-07-23 23:18:02 -07:00
|
|
|
bool isGlobal(jsval* p) const;
|
|
|
|
ptrdiff_t nativeGlobalOffset(jsval* p) const;
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK ptrdiff_t nativeStackOffset(jsval* p) const;
|
|
|
|
JS_REQUIRES_STACK void import(nanojit::LIns* base, ptrdiff_t offset, jsval* p, uint8& t,
|
|
|
|
const char *prefix, uintN index, JSStackFrame *fp);
|
2009-01-21 22:45:19 -08:00
|
|
|
JS_REQUIRES_STACK void import(TreeInfo* treeInfo, nanojit::LIns* sp, unsigned stackSlots,
|
|
|
|
unsigned callDepth, unsigned ngslots, uint8* typeMap);
|
2008-07-23 23:18:02 -07:00
|
|
|
void trackNativeStackUse(unsigned slots);
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool lazilyImportGlobalSlot(unsigned slot);
|
2008-08-29 18:59:21 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* guard(bool expected, nanojit::LIns* cond,
|
|
|
|
ExitType exitType);
|
2008-10-28 22:40:10 -07:00
|
|
|
nanojit::LIns* guard(bool expected, nanojit::LIns* cond, nanojit::LIns* exit);
|
2008-12-21 03:55:09 -08:00
|
|
|
|
2008-07-17 02:00:23 -07:00
|
|
|
nanojit::LIns* addName(nanojit::LIns* ins, const char* name);
|
2008-06-30 17:12:52 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* get(jsval* p) const;
|
2008-08-15 14:47:49 -07:00
|
|
|
nanojit::LIns* writeBack(nanojit::LIns* i, nanojit::LIns* base, ptrdiff_t offset);
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK void set(jsval* p, nanojit::LIns* l, bool initializing = false);
|
2008-07-06 11:48:41 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool checkType(jsval& v, uint8 t, jsval*& stage_val,
|
|
|
|
nanojit::LIns*& stage_ins, unsigned& stage_count);
|
|
|
|
JS_REQUIRES_STACK bool deduceTypeStability(nanojit::Fragment* root_peer,
|
2009-01-21 22:45:19 -08:00
|
|
|
nanojit::Fragment** stable_peer,
|
|
|
|
bool& demote);
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK jsval& argval(unsigned n) const;
|
|
|
|
JS_REQUIRES_STACK jsval& varval(unsigned n) const;
|
|
|
|
JS_REQUIRES_STACK jsval& stackval(int n) const;
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* scopeChain() const;
|
|
|
|
JS_REQUIRES_STACK bool activeCallOrGlobalSlot(JSObject* obj, jsval*& vp);
|
2008-08-20 22:40:39 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* arg(unsigned n);
|
|
|
|
JS_REQUIRES_STACK void arg(unsigned n, nanojit::LIns* i);
|
|
|
|
JS_REQUIRES_STACK nanojit::LIns* var(unsigned n);
|
|
|
|
JS_REQUIRES_STACK void var(unsigned n, nanojit::LIns* i);
|
|
|
|
JS_REQUIRES_STACK nanojit::LIns* stack(int n);
|
|
|
|
JS_REQUIRES_STACK void stack(int n, nanojit::LIns* i);
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2009-01-07 14:14:51 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* alu(nanojit::LOpcode op, jsdouble v0, jsdouble v1,
|
|
|
|
nanojit::LIns* s0, nanojit::LIns* s1);
|
2008-07-06 15:55:04 -07:00
|
|
|
nanojit::LIns* f2i(nanojit::LIns* f);
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* makeNumberInt32(nanojit::LIns* f);
|
2009-01-07 14:14:51 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::LIns* stringify(jsval& v);
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2009-01-07 14:14:51 -08:00
|
|
|
JS_REQUIRES_STACK bool call_imacro(jsbytecode* imacro);
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool ifop();
|
|
|
|
JS_REQUIRES_STACK bool switchop();
|
|
|
|
JS_REQUIRES_STACK bool inc(jsval& v, jsint incr, bool pre = true);
|
|
|
|
JS_REQUIRES_STACK bool inc(jsval& v, nanojit::LIns*& v_ins, jsint incr, bool pre = true);
|
|
|
|
JS_REQUIRES_STACK bool incProp(jsint incr, bool pre = true);
|
|
|
|
JS_REQUIRES_STACK bool incElem(jsint incr, bool pre = true);
|
|
|
|
JS_REQUIRES_STACK bool incName(jsint incr, bool pre = true);
|
2008-08-28 23:50:48 -07:00
|
|
|
|
2008-12-18 10:35:09 -08:00
|
|
|
JS_REQUIRES_STACK void strictEquality(bool equal, bool cmpCase);
|
|
|
|
JS_REQUIRES_STACK bool equality(bool negate, bool tryBranchAfterCond);
|
2008-12-26 11:48:33 -08:00
|
|
|
JS_REQUIRES_STACK bool equalityHelper(jsval l, jsval r,
|
|
|
|
nanojit::LIns* l_ins, nanojit::LIns* r_ins,
|
|
|
|
bool negate, bool tryBranchAfterCond,
|
|
|
|
jsval& rval);
|
2008-12-18 10:35:09 -08:00
|
|
|
JS_REQUIRES_STACK bool relational(nanojit::LOpcode op, bool tryBranchAfterCond);
|
2008-07-06 13:16:34 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool unary(nanojit::LOpcode op);
|
|
|
|
JS_REQUIRES_STACK bool binary(nanojit::LOpcode op);
|
2008-07-07 02:21:04 -07:00
|
|
|
|
|
|
|
bool ibinary(nanojit::LOpcode op);
|
2008-07-05 22:04:58 -07:00
|
|
|
bool iunary(nanojit::LOpcode op);
|
2008-07-07 02:21:04 -07:00
|
|
|
bool bbinary(nanojit::LOpcode op);
|
2008-07-05 23:21:53 -07:00
|
|
|
void demote(jsval& v, jsdouble result);
|
2008-07-07 02:21:04 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool map_is_native(JSObjectMap* map, nanojit::LIns* map_ins,
|
|
|
|
nanojit::LIns*& ops_ins, size_t op_offset = 0);
|
|
|
|
JS_REQUIRES_STACK bool test_property_cache(JSObject* obj, nanojit::LIns* obj_ins,
|
|
|
|
JSObject*& obj2, jsuword& pcval);
|
|
|
|
JS_REQUIRES_STACK bool test_property_cache_direct_slot(JSObject* obj, nanojit::LIns* obj_ins,
|
|
|
|
uint32& slot);
|
2008-11-05 05:29:38 -08:00
|
|
|
void stobj_set_slot(nanojit::LIns* obj_ins, unsigned slot, nanojit::LIns*& dslots_ins,
|
|
|
|
nanojit::LIns* v_ins);
|
|
|
|
void stobj_set_dslot(nanojit::LIns *obj_ins, unsigned slot, nanojit::LIns*& dslots_ins,
|
|
|
|
nanojit::LIns* v_ins, const char *name);
|
|
|
|
|
2008-07-30 16:32:33 -07:00
|
|
|
nanojit::LIns* stobj_get_fslot(nanojit::LIns* obj_ins, unsigned slot);
|
2008-07-07 02:21:04 -07:00
|
|
|
nanojit::LIns* stobj_get_slot(nanojit::LIns* obj_ins, unsigned slot,
|
2008-07-07 02:55:03 -07:00
|
|
|
nanojit::LIns*& dslots_ins);
|
2008-07-07 02:21:04 -07:00
|
|
|
bool native_set(nanojit::LIns* obj_ins, JSScopeProperty* sprop,
|
2008-07-07 02:55:03 -07:00
|
|
|
nanojit::LIns*& dslots_ins, nanojit::LIns* v_ins);
|
2008-07-07 02:21:04 -07:00
|
|
|
bool native_get(nanojit::LIns* obj_ins, nanojit::LIns* pobj_ins, JSScopeProperty* sprop,
|
2008-07-07 02:55:03 -07:00
|
|
|
nanojit::LIns*& dslots_ins, nanojit::LIns*& v_ins);
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool name(jsval*& vp);
|
|
|
|
JS_REQUIRES_STACK bool prop(JSObject* obj, nanojit::LIns* obj_ins, uint32& slot,
|
|
|
|
nanojit::LIns*& v_ins);
|
|
|
|
JS_REQUIRES_STACK bool elem(jsval& oval, jsval& idx, jsval*& vp, nanojit::LIns*& v_ins,
|
|
|
|
nanojit::LIns*& addr_ins);
|
|
|
|
JS_REQUIRES_STACK bool getProp(JSObject* obj, nanojit::LIns* obj_ins);
|
|
|
|
JS_REQUIRES_STACK bool getProp(jsval& v);
|
|
|
|
JS_REQUIRES_STACK bool getThis(nanojit::LIns*& this_ins);
|
|
|
|
|
2009-01-10 12:15:08 -08:00
|
|
|
JS_REQUIRES_STACK void box_jsval(jsval v, nanojit::LIns*& v_ins);
|
2009-01-11 13:57:42 -08:00
|
|
|
JS_REQUIRES_STACK void unbox_jsval(jsval v, nanojit::LIns*& v_ins);
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool guardClass(JSObject* obj, nanojit::LIns* obj_ins, JSClass* clasp,
|
|
|
|
ExitType exitType = MISMATCH_EXIT);
|
|
|
|
JS_REQUIRES_STACK bool guardDenseArray(JSObject* obj, nanojit::LIns* obj_ins,
|
|
|
|
ExitType exitType = MISMATCH_EXIT);
|
|
|
|
JS_REQUIRES_STACK bool guardDenseArrayIndex(JSObject* obj, jsint idx, nanojit::LIns* obj_ins,
|
|
|
|
nanojit::LIns* dslots_ins, nanojit::LIns* idx_ins,
|
|
|
|
ExitType exitType);
|
|
|
|
JS_REQUIRES_STACK bool guardElemOp(JSObject* obj, nanojit::LIns* obj_ins, jsid id,
|
|
|
|
size_t op_offset, jsval* vp);
|
2008-07-24 10:35:10 -07:00
|
|
|
void clearFrameSlotsFromCache();
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool guardCallee(jsval& callee);
|
|
|
|
JS_REQUIRES_STACK bool getClassPrototype(JSObject* ctor, nanojit::LIns*& proto_ins);
|
|
|
|
JS_REQUIRES_STACK bool newArray(JSObject* ctor, uint32 argc, jsval* argv, jsval* vp);
|
|
|
|
JS_REQUIRES_STACK bool interpretedFunctionCall(jsval& fval, JSFunction* fun, uintN argc,
|
|
|
|
bool constructing);
|
|
|
|
JS_REQUIRES_STACK bool functionCall(bool constructing, uintN argc);
|
2008-07-31 16:30:00 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK void trackCfgMerges(jsbytecode* pc);
|
|
|
|
JS_REQUIRES_STACK void flipIf(jsbytecode* pc, bool& cond);
|
|
|
|
JS_REQUIRES_STACK void fuseIf(jsbytecode* pc, bool cond, nanojit::LIns* x);
|
2008-09-05 18:29:08 -07:00
|
|
|
|
2008-11-13 00:30:20 -08:00
|
|
|
bool hasMethod(JSObject* obj, jsid id);
|
2009-01-26 11:26:24 -08:00
|
|
|
JS_REQUIRES_STACK bool hasIteratorMethod(JSObject* obj);
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-03 23:57:57 -07:00
|
|
|
public:
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK
|
2008-11-07 15:23:43 -08:00
|
|
|
TraceRecorder(JSContext* cx, VMSideExit*, nanojit::Fragment*, TreeInfo*,
|
2009-01-21 22:45:19 -08:00
|
|
|
unsigned stackSlots, unsigned ngslots, uint8* typeMap,
|
2008-11-13 00:30:20 -08:00
|
|
|
VMSideExit* expectedInnerExit, nanojit::Fragment* outerToBlacklist);
|
2008-07-03 23:57:57 -07:00
|
|
|
~TraceRecorder();
|
|
|
|
|
2009-01-05 16:13:53 -08:00
|
|
|
static JS_REQUIRES_STACK JSMonitorRecordingStatus monitorRecording(JSContext* cx, TraceRecorder* tr, JSOp op);
|
2008-12-21 03:55:09 -08:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK uint8 determineSlotType(jsval* vp) const;
|
|
|
|
JS_REQUIRES_STACK nanojit::LIns* snapshot(ExitType exitType);
|
2008-07-17 01:29:41 -07:00
|
|
|
nanojit::Fragment* getFragment() const { return fragment; }
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool isLoopHeader(JSContext* cx) const;
|
|
|
|
JS_REQUIRES_STACK void compile(nanojit::Fragmento* fragmento);
|
2009-01-21 22:45:19 -08:00
|
|
|
JS_REQUIRES_STACK bool closeLoop(nanojit::Fragmento* fragmento, bool& demote);
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK void endLoop(nanojit::Fragmento* fragmento);
|
|
|
|
JS_REQUIRES_STACK void joinEdgesToEntry(nanojit::Fragmento* fragmento,
|
|
|
|
nanojit::Fragment* peer_root);
|
2008-08-06 22:26:20 -07:00
|
|
|
void blacklist() { fragment->blacklist(); }
|
2009-01-21 22:45:19 -08:00
|
|
|
JS_REQUIRES_STACK bool adjustCallerTypes(nanojit::Fragment* f);
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK nanojit::Fragment* findNestedCompatiblePeer(nanojit::Fragment* f,
|
|
|
|
nanojit::Fragment** empty);
|
|
|
|
JS_REQUIRES_STACK void prepareTreeCall(nanojit::Fragment* inner);
|
|
|
|
JS_REQUIRES_STACK void emitTreeCall(nanojit::Fragment* inner, VMSideExit* exit);
|
2008-08-07 16:41:20 -07:00
|
|
|
unsigned getCallDepth() const;
|
2008-11-15 16:54:24 -08:00
|
|
|
void pushAbortStack();
|
|
|
|
void popAbortStack();
|
|
|
|
void removeFragmentoReferences();
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool record_EnterFrame();
|
|
|
|
JS_REQUIRES_STACK bool record_LeaveFrame();
|
|
|
|
JS_REQUIRES_STACK bool record_SetPropHit(JSPropCacheEntry* entry, JSScopeProperty* sprop);
|
|
|
|
JS_REQUIRES_STACK bool record_SetPropMiss(JSPropCacheEntry* entry);
|
|
|
|
JS_REQUIRES_STACK bool record_DefLocalFunSetSlot(uint32 slot, JSObject* obj);
|
|
|
|
JS_REQUIRES_STACK bool record_FastNativeCallComplete();
|
2009-01-25 16:38:31 -08:00
|
|
|
JS_REQUIRES_STACK bool record_IteratorNextComplete();
|
2008-12-09 08:38:32 -08:00
|
|
|
|
2008-10-27 20:42:49 -07:00
|
|
|
nanojit::Fragment* getOuterToBlacklist() { return outerToBlacklist; }
|
2008-08-29 18:59:21 -07:00
|
|
|
void deepAbort() { deepAborted = true; }
|
|
|
|
bool wasDeepAborted() { return deepAborted; }
|
2008-10-08 21:02:04 -07:00
|
|
|
bool walkedOutOfLoop() { return terminate; }
|
2008-10-27 20:42:49 -07:00
|
|
|
TreeInfo* getTreeInfo() { return treeInfo; }
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-07-07 02:21:04 -07:00
|
|
|
#define OPDEF(op,val,name,token,length,nuses,ndefs,prec,format) \
|
2008-12-09 08:38:32 -08:00
|
|
|
JS_REQUIRES_STACK bool record_##op();
|
2008-07-07 02:21:04 -07:00
|
|
|
# include "jsopcode.tbl"
|
|
|
|
#undef OPDEF
|
2008-06-22 09:30:04 -07:00
|
|
|
};
|
2008-06-27 08:41:59 -07:00
|
|
|
#define TRACING_ENABLED(cx) JS_HAS_OPTION(cx, JSOPTION_JIT)
|
2008-09-09 22:22:52 -07:00
|
|
|
#define TRACE_RECORDER(cx) (JS_TRACE_MONITOR(cx).recorder)
|
|
|
|
#define SET_TRACE_RECORDER(cx,tr) (JS_TRACE_MONITOR(cx).recorder = (tr))
|
2008-05-30 18:58:43 -07:00
|
|
|
|
2008-11-13 00:30:20 -08:00
|
|
|
#define JSOP_IS_BINARY(op) ((uintN)((op) - JSOP_BITOR) <= (uintN)(JSOP_MOD - JSOP_BITOR))
|
2008-12-19 19:30:09 -08:00
|
|
|
#define JSOP_IS_UNARY(op) ((uintN)((op) - JSOP_NEG) <= (uintN)(JSOP_POS - JSOP_NEG))
|
2008-12-26 11:48:33 -08:00
|
|
|
#define JSOP_IS_EQUALITY(op) ((uintN)((op) - JSOP_EQ) <= (uintN)(JSOP_NE - JSOP_EQ))
|
2008-11-13 00:30:20 -08:00
|
|
|
|
2008-12-21 03:55:09 -08:00
|
|
|
#define TRACE_ARGS_(x,args) \
|
2008-09-09 22:22:52 -07:00
|
|
|
JS_BEGIN_MACRO \
|
2008-11-13 00:30:20 -08:00
|
|
|
TraceRecorder* tr_ = TRACE_RECORDER(cx); \
|
2008-12-21 03:55:09 -08:00
|
|
|
if (tr_ && !tr_->record_##x args) \
|
2008-10-09 16:17:13 -07:00
|
|
|
js_AbortRecording(cx, #x); \
|
2008-07-16 22:58:06 -07:00
|
|
|
JS_END_MACRO
|
|
|
|
|
2008-12-21 03:55:09 -08:00
|
|
|
#define TRACE_ARGS(x,args) TRACE_ARGS_(x, args)
|
2008-09-18 16:53:09 -07:00
|
|
|
#define TRACE_0(x) TRACE_ARGS(x, ())
|
2008-09-09 22:22:52 -07:00
|
|
|
#define TRACE_1(x,a) TRACE_ARGS(x, (a))
|
|
|
|
#define TRACE_2(x,a,b) TRACE_ARGS(x, (a, b))
|
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
extern JS_REQUIRES_STACK bool
|
2008-10-09 16:17:13 -07:00
|
|
|
js_MonitorLoopEdge(JSContext* cx, uintN& inlineCallCount);
|
2008-08-28 22:33:22 -07:00
|
|
|
|
2008-12-21 03:55:09 -08:00
|
|
|
#ifdef DEBUG
|
|
|
|
# define js_AbortRecording(cx, reason) js_AbortRecordingImpl(cx, reason)
|
|
|
|
#else
|
|
|
|
# define js_AbortRecording(cx, reason) js_AbortRecordingImpl(cx)
|
|
|
|
#endif
|
2008-06-11 17:21:15 -07:00
|
|
|
|
2008-12-09 08:38:32 -08:00
|
|
|
extern JS_REQUIRES_STACK void
|
2008-10-09 16:17:13 -07:00
|
|
|
js_AbortRecording(JSContext* cx, const char* reason);
|
2008-06-28 18:19:21 -07:00
|
|
|
|
2008-07-05 19:15:00 -07:00
|
|
|
extern void
|
2008-08-11 18:47:22 -07:00
|
|
|
js_InitJIT(JSTraceMonitor *tm);
|
2008-07-05 19:15:00 -07:00
|
|
|
|
2008-07-17 10:22:40 -07:00
|
|
|
extern void
|
2008-08-11 19:17:30 -07:00
|
|
|
js_FinishJIT(JSTraceMonitor *tm);
|
2008-07-17 10:22:40 -07:00
|
|
|
|
2008-08-06 21:56:25 -07:00
|
|
|
extern void
|
|
|
|
js_FlushJITCache(JSContext* cx);
|
|
|
|
|
2008-08-20 16:01:56 -07:00
|
|
|
extern void
|
|
|
|
js_FlushJITOracle(JSContext* cx);
|
|
|
|
|
2008-09-11 15:53:00 -07:00
|
|
|
#else /* !JS_TRACER */
|
|
|
|
|
2008-09-22 13:04:47 -07:00
|
|
|
#define TRACE_0(x) ((void)0)
|
2008-09-11 15:53:00 -07:00
|
|
|
#define TRACE_1(x,a) ((void)0)
|
|
|
|
#define TRACE_2(x,a,b) ((void)0)
|
|
|
|
|
|
|
|
#endif /* !JS_TRACER */
|
2008-08-12 08:36:29 -07:00
|
|
|
|
2008-05-31 15:29:54 -07:00
|
|
|
#endif /* jstracer_h___ */
|