Commit 2391467b authored by Marius Wachtler's avatar Marius Wachtler

enable PyStringObject: we use now the same layout as cpython

parent ad0315d4
......@@ -33,8 +33,6 @@ functions should be applied to nil objects.
interning of any string.
Together, these sped the interpreter by up to 20%. */
// Pyston change: comment this out since this is not the format we're using
#if 0
typedef struct {
PyObject_VAR_HEAD
long ob_shash;
......@@ -50,9 +48,6 @@ typedef struct {
* from 'interned' to this object are *not counted* in ob_refcnt.
*/
} PyStringObject;
#endif
struct _PyStringObject;
typedef struct _PyStringObject PyStringObject;
#define SSTATE_NOT_INTERNED 0
#define SSTATE_INTERNED_MORTAL 1
......
......@@ -408,7 +408,8 @@ public:
llvm::StringRef s() const { return llvm::StringRef(s_data, ob_size); };
long hash; // -1 means not yet computed
char interned_state;
int interned_state;
char s_data[0];
char* data() { return s_data; }
const char* c_str() {
......@@ -463,10 +464,13 @@ private:
BoxedString(size_t n); // non-initializing constructor
char s_data[0];
friend void setupRuntime();
};
static_assert(sizeof(BoxedString) == sizeof(PyStringObject), "");
static_assert(offsetof(BoxedString, ob_size) == offsetof(PyStringObject, ob_size), "");
static_assert(offsetof(BoxedString, hash) == offsetof(PyStringObject, ob_shash), "");
static_assert(offsetof(BoxedString, interned_state) == offsetof(PyStringObject, ob_sstate), "");
static_assert(offsetof(BoxedString, s_data) == offsetof(PyStringObject, ob_sval), "");
extern "C" size_t strHashUnboxed(BoxedString* self);
extern "C" int64_t hashUnboxed(Box* obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment