Backed out 8 changesets (bug 1147403) for debug asserts on a CLOSED TREE.
Backed out changeset a1018d31e591 (bug 1147403) Backed out changeset fdb1dcf35e04 (bug 1147403) Backed out changeset 66ab1f789052 (bug 1147403) Backed out changeset 8ee01e148887 (bug 1147403) Backed out changeset 615c601284e3 (bug 1147403) Backed out changeset d7a4b4c31c94 (bug 1147403) Backed out changeset b1abceaf0f6e (bug 1147403) Backed out changeset 443b1a2a084f (bug 1147403)
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
|
||||
#include "frontend/SourceNotes.h"
|
||||
#include "vm/Opcodes.h"
|
||||
#include "vm/Printer.h"
|
||||
|
||||
/*
|
||||
* JS operation bytecodes.
|
||||
@@ -383,6 +382,7 @@ struct JSCodeSpec {
|
||||
extern const JSCodeSpec js_CodeSpec[];
|
||||
extern const unsigned js_NumCodeSpecs;
|
||||
extern const char * const js_CodeName[];
|
||||
extern const char js_EscapeMap[];
|
||||
|
||||
/* Shorthand for type from opcode. */
|
||||
|
||||
@@ -400,6 +400,14 @@ JOF_OPTYPE(JSOp op)
|
||||
|
||||
namespace js {
|
||||
|
||||
/*
|
||||
* Return a GC'ed string containing the chars in str, with any non-printing
|
||||
* chars or quotes (' or " as specified by the quote argument) escaped, and
|
||||
* with the quote character at the beginning and end of the result string.
|
||||
*/
|
||||
extern JSString*
|
||||
QuoteString(ExclusiveContext* cx, JSString* str, char16_t quote);
|
||||
|
||||
static inline bool
|
||||
IsJumpOpcode(JSOp op)
|
||||
{
|
||||
@@ -569,6 +577,89 @@ DecompileValueGenerator(JSContext* cx, int spindex, HandleValue v,
|
||||
char*
|
||||
DecompileArgument(JSContext* cx, int formalIndex, HandleValue v);
|
||||
|
||||
/*
|
||||
* Sprintf, but with unlimited and automatically allocated buffering.
|
||||
*/
|
||||
class Sprinter
|
||||
{
|
||||
public:
|
||||
struct InvariantChecker
|
||||
{
|
||||
const Sprinter* parent;
|
||||
|
||||
explicit InvariantChecker(const Sprinter* p) : parent(p) {
|
||||
parent->checkInvariants();
|
||||
}
|
||||
|
||||
~InvariantChecker() {
|
||||
parent->checkInvariants();
|
||||
}
|
||||
};
|
||||
|
||||
ExclusiveContext* context; /* context executing the decompiler */
|
||||
|
||||
private:
|
||||
static const size_t DefaultSize;
|
||||
#ifdef DEBUG
|
||||
bool initialized; /* true if this is initialized, use for debug builds */
|
||||
#endif
|
||||
char* base; /* malloc'd buffer address */
|
||||
size_t size; /* size of buffer allocated at base */
|
||||
ptrdiff_t offset; /* offset of next free char in buffer */
|
||||
bool reportedOOM; /* this sprinter has reported OOM in string ops */
|
||||
|
||||
bool realloc_(size_t newSize);
|
||||
|
||||
public:
|
||||
explicit Sprinter(ExclusiveContext* cx);
|
||||
~Sprinter();
|
||||
|
||||
/* Initialize this sprinter, returns false on error */
|
||||
bool init();
|
||||
|
||||
void checkInvariants() const;
|
||||
|
||||
const char* string() const;
|
||||
const char* stringEnd() const;
|
||||
/* Returns the string at offset |off| */
|
||||
char* stringAt(ptrdiff_t off) const;
|
||||
/* Returns the char at offset |off| */
|
||||
char& operator[](size_t off);
|
||||
|
||||
/*
|
||||
* Attempt to reserve len + 1 space (for a trailing nullptr byte). If the
|
||||
* attempt succeeds, return a pointer to the start of that space and adjust the
|
||||
* internal content. The caller *must* completely fill this space on success.
|
||||
*/
|
||||
char* reserve(size_t len);
|
||||
|
||||
/*
|
||||
* Puts |len| characters from |s| at the current position and return an offset to
|
||||
* the beginning of this new data
|
||||
*/
|
||||
ptrdiff_t put(const char* s, size_t len);
|
||||
ptrdiff_t put(const char* s);
|
||||
ptrdiff_t putString(JSString* str);
|
||||
|
||||
/* Prints a formatted string into the buffer */
|
||||
int printf(const char* fmt, ...);
|
||||
|
||||
ptrdiff_t getOffset() const;
|
||||
|
||||
/*
|
||||
* Report that a string operation failed to get the memory it requested. The
|
||||
* first call to this function calls JS_ReportOutOfMemory, and sets this
|
||||
* Sprinter's outOfMemory flag; subsequent calls do nothing.
|
||||
*/
|
||||
void reportOutOfMemory();
|
||||
|
||||
/* Return true if this Sprinter ran out of memory. */
|
||||
bool hadOutOfMemory() const;
|
||||
};
|
||||
|
||||
extern ptrdiff_t
|
||||
Sprint(Sprinter* sp, const char* format, ...);
|
||||
|
||||
extern bool
|
||||
CallResultEscapes(jsbytecode* pc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user