#define Identifier_h
#include "JSGlobalData.h"
+#include "ThreadSpecific.h"
#include "UString.h"
namespace JSC {
const char* ascii() const { return _ustring.ascii(); }
static Identifier from(ExecState* exec, unsigned y) { return Identifier(exec, UString::from(y)); }
+ static Identifier from(ExecState* exec, int y) { return Identifier(exec, UString::from(y)); }
+ static Identifier from(ExecState* exec, double y) { return Identifier(exec, UString::from(y)); }
bool isNull() const { return _ustring.isNull(); }
bool isEmpty() const { return _ustring.isEmpty(); }
static PassRefPtr<UString::Rep> add(ExecState* exec, UString::Rep* r)
{
- if (r->identifierTable()) {
+ if (r->isIdentifier()) {
#ifndef NDEBUG
checkSameIdentifierTable(exec, r);
#endif
}
static PassRefPtr<UString::Rep> add(JSGlobalData* globalData, UString::Rep* r)
{
- if (r->identifierTable()) {
+ if (r->isIdentifier()) {
#ifndef NDEBUG
checkSameIdentifierTable(globalData, r);
#endif
IdentifierTable* createIdentifierTable();
void deleteIdentifierTable(IdentifierTable*);
+ struct ThreadIdentifierTableData {
+ ThreadIdentifierTableData()
+ : defaultIdentifierTable(0)
+ , currentIdentifierTable(0)
+ {
+ }
+
+ IdentifierTable* defaultIdentifierTable;
+ IdentifierTable* currentIdentifierTable;
+ };
+
+ extern WTF::ThreadSpecific<ThreadIdentifierTableData>* g_identifierTableSpecific;
+ extern ThreadIdentifierTableData* g_identifierTableMain;
+ void createIdentifierTableSpecific();
+
+ inline IdentifierTable* defaultIdentifierTable()
+ {
+ if (isMainThread() || pthread_main_np()) {
+ if (!g_identifierTableMain)
+ createIdentifierTableSpecific();
+ return g_identifierTableMain->defaultIdentifierTable;
+ }
+ if (!g_identifierTableSpecific)
+ createIdentifierTableSpecific();
+ ThreadIdentifierTableData& data = **g_identifierTableSpecific;
+
+ return data.defaultIdentifierTable;
+ }
+
+ inline void setDefaultIdentifierTable(IdentifierTable* identifierTable)
+ {
+ if (isMainThread() || pthread_main_np()) {
+ if (!g_identifierTableMain)
+ createIdentifierTableSpecific();
+ g_identifierTableMain->defaultIdentifierTable = identifierTable;
+ return;
+ }
+ if (!g_identifierTableSpecific)
+ createIdentifierTableSpecific();
+ ThreadIdentifierTableData& data = **g_identifierTableSpecific;
+
+ data.defaultIdentifierTable = identifierTable;
+ }
+
+ inline IdentifierTable* currentIdentifierTable()
+ {
+ if (isMainThread() || pthread_main_np()) {
+ if (!g_identifierTableMain)
+ createIdentifierTableSpecific();
+ return g_identifierTableMain->currentIdentifierTable;
+ }
+ if (!g_identifierTableSpecific)
+ createIdentifierTableSpecific();
+ ThreadIdentifierTableData& data = **g_identifierTableSpecific;
+
+ return data.currentIdentifierTable;
+ }
+
+ inline IdentifierTable* setCurrentIdentifierTable(IdentifierTable* identifierTable)
+ {
+ if (isMainThread() || pthread_main_np()) {
+ if (!g_identifierTableMain)
+ createIdentifierTableSpecific();
+ IdentifierTable* oldIdentifierTable = g_identifierTableMain->currentIdentifierTable;
+ g_identifierTableMain->currentIdentifierTable = identifierTable;
+ return oldIdentifierTable;
+ }
+ if (!g_identifierTableSpecific)
+ createIdentifierTableSpecific();
+ ThreadIdentifierTableData& data = **g_identifierTableSpecific;
+
+ IdentifierTable* oldIdentifierTable = data.currentIdentifierTable;
+ data.currentIdentifierTable = identifierTable;
+ return oldIdentifierTable;
+ }
+
+ inline void resetCurrentIdentifierTable()
+ {
+ if (isMainThread() || pthread_main_np()) {
+ if (!g_identifierTableMain)
+ createIdentifierTableSpecific();
+ g_identifierTableMain->currentIdentifierTable = g_identifierTableMain->defaultIdentifierTable;
+ return;
+ }
+ if (!g_identifierTableSpecific)
+ createIdentifierTableSpecific();
+ ThreadIdentifierTableData& data = **g_identifierTableSpecific;
+
+ data.currentIdentifierTable = data.defaultIdentifierTable;
+ }
+
} // namespace JSC
#endif // Identifier_h