Changeset 1789 in webkit for trunk/JavaScriptCore/kjs/internal.cpp
- Timestamp:
- Aug 9, 2002, 4:24:41 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.cpp
r1623 r1789 68 68 const double Inf = *(const double*) Inf_Bytes; 69 69 }; 70 71 #ifdef APPLE_CHANGES 72 static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT; 73 static pthread_mutex_t interpreterLock; 74 75 static void initializeInterpreterLock() 76 { 77 pthread_mutexattr_t attr; 78 79 pthread_mutexattr_init(&attr); 80 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); 81 82 pthread_mutex_init(&interpreterLock, &attr); 83 } 84 85 static inline void lockInterpreter() 86 { 87 pthread_once(&interpreterLockOnce, initializeInterpreterLock); 88 pthread_mutex_lock(&interpreterLock); 89 } 90 91 static inline void unlockInterpreter() 92 { 93 pthread_mutex_unlock(&interpreterLock); 94 } 95 96 #endif 97 70 98 71 99 // ------------------------------ UndefinedImp --------------------------------- … … 689 717 ProgramNode *Parser::progNode = 0; 690 718 int Parser::sid = 0; 691 #ifdef APPLE_CHANGES692 static pthread_mutex_t parserLock = PTHREAD_MUTEX_INITIALIZER;693 #endif694 719 695 720 ProgramNode *Parser::parse(const UChar *code, unsigned int length, int *sourceId, 696 721 int *errLine, UString *errMsg) 697 722 { 698 #ifdef APPLE_CHANGES699 pthread_mutex_lock(&parserLock);700 #endif701 723 if (errLine) 702 724 *errLine = -1; … … 727 749 #endif 728 750 delete prog; 729 #ifdef APPLE_CHANGES730 pthread_mutex_unlock(&parserLock);731 #endif732 751 return 0; 733 752 } 734 753 735 #ifdef APPLE_CHANGES736 pthread_mutex_unlock(&parserLock);737 #endif738 754 return prog; 739 755 } … … 778 794 // as a root set for garbage collection 779 795 #ifdef APPLE_CHANGES 780 Collector::lock();796 pthread_mutex_lock(&interpreterLock); 781 797 m_interpreter = interp; 782 798 #endif … … 792 808 } 793 809 #ifdef APPLE_CHANGES 794 Collector::unlock();810 pthread_mutex_unlock(&interpreterLock); 795 811 #endif 796 812 … … 939 955 // remove from global chain (see init()) 940 956 #ifdef APPLE_CHANGES 941 Collector::lock();957 pthread_mutex_lock(&interpreterLock); 942 958 #endif 943 959 next->prev = prev; … … 951 967 } 952 968 #ifdef APPLE_CHANGES 953 Collector::unlock();969 pthread_mutex_unlock(&interpreterLock); 954 970 #endif 955 971 } … … 989 1005 Completion InterpreterImp::evaluate(const UString &code, const Value &thisV) 990 1006 { 1007 #ifdef APPLE_CHANGES 1008 pthread_mutex_lock(&interpreterLock); 1009 #endif 991 1010 // prevent against infinite recursion 992 1011 if (recursion >= 20) { 1012 #ifdef APPLE_CHANGES 1013 Completion result = Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep")); 1014 pthread_mutex_unlock(&interpreterLock); 1015 return result; 1016 #else 993 1017 return Completion(Throw,Error::create(globExec,GeneralError,"Recursion too deep")); 1018 #endif 994 1019 } 995 1020 … … 1004 1029 bool cont = dbg->sourceParsed(globExec,sid,code,errLine); 1005 1030 if (!cont) 1031 #ifdef APPLE_CHANGES 1032 { 1033 pthread_mutex_unlock(&interpreterLock); 1034 return Completion(Break); 1035 } 1036 #else 1006 1037 return Completion(Break); 1038 #endif 1007 1039 } 1008 1040 … … 1011 1043 Object err = Error::create(globExec,SyntaxError,errMsg.ascii(),errLine); 1012 1044 err.put(globExec,"sid",Number(sid)); 1045 #ifdef APPLE_CHANGES 1046 pthread_mutex_unlock(&interpreterLock); 1047 #endif 1013 1048 return Completion(Throw,err); 1014 1049 } … … 1053 1088 recursion--; 1054 1089 1090 #ifdef APPLE_CHANGES 1091 pthread_mutex_unlock(&interpreterLock); 1092 #endif 1055 1093 return res; 1056 1094 }
Note:
See TracChangeset
for help on using the changeset viewer.