Changeset 10456 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Sep 3, 2005, 6:18:13 PM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/collector.cpp
r10197 r10456 29 29 #include <algorithm> 30 30 31 #if APPLE_CHANGES 31 #if !WIN32 32 32 33 #include <CoreFoundation/CoreFoundation.h> 33 34 #include <pthread.h> … … 35 36 #include <mach/task.h> 36 37 #include <mach/thread_act.h> 38 39 #else 40 41 #include <windows.h> 42 37 43 #endif 38 44 … … 174 180 } 175 181 182 #if KJS_MULTIPLE_THREADS 183 176 184 struct Collector::Thread { 177 185 Thread(pthread_t pthread, mach_port_t mthread) : posixThread(pthread), machThread(mthread) {} … … 222 230 } 223 231 } 232 233 #endif 224 234 225 235 #define IS_POINTER_ALIGNED(p) (((int)(p) & (sizeof(char *) - 1)) == 0) … … 275 285 void Collector::markCurrentThreadConservatively() 276 286 { 277 jmp_buf registers; 278 setjmp(registers); 279 280 pthread_t thread = pthread_self(); 281 void *stackBase = pthread_get_stackaddr_np(thread); 282 int dummy; 283 void *stackPointer = &dummy; 284 markStackObjectsConservatively(stackPointer, stackBase); 285 } 287 jmp_buf registers; 288 setjmp(registers); 289 290 #if !WIN32 291 pthread_t thread = pthread_self(); 292 void *stackBase = pthread_get_stackaddr_np(thread); 293 #else 294 NT_TIB *pTib; 295 __asm { 296 MOV EAX, FS:[18h] 297 MOV pTib, EAX 298 } 299 void *stackBase = (void *)pTib->StackBase; 300 #endif 301 302 int dummy; 303 void *stackPointer = &dummy; 304 305 markStackObjectsConservatively(stackPointer, stackBase); 306 } 307 308 #if KJS_MULTIPLE_THREADS 286 309 287 310 typedef unsigned long usword_t; // word size, assumed to be either 32 or 64 bit … … 324 347 } 325 348 349 #endif 350 326 351 void Collector::markStackObjectsConservatively() 327 352 { 328 353 markCurrentThreadConservatively(); 329 354 355 #if KJS_MULTIPLE_THREADS 330 356 for (Thread *thread = registeredThreads; thread != NULL; thread = thread->next) { 331 357 if (thread->posixThread != pthread_self()) { … … 333 359 } 334 360 } 361 #endif 335 362 } 336 363 -
trunk/JavaScriptCore/kjs/config.h
r10412 r10456 12 12 #define HAVE_FLOAT_H 1 13 13 #define HAVE_FUNC__FINITE 1 14 #define HAVE_SYS_TIMEB_H 1 14 15 15 16 #endif -
trunk/JavaScriptCore/kjs/date_object.cpp
r10207 r10456 52 52 #include <locale.h> 53 53 #include <ctype.h> 54 #include <limits.h> 54 55 55 56 #include "date_object.h" 56 57 #include "error_object.h" 57 58 #include "operations.h" 59 60 #if WIN32 61 #define strncasecmp(x, y, z) strnicmp(x, y, z) 62 #include <float.h> 63 #define isfinite(x) _finite(x) 64 #define copysign(x) _copysign(x) 65 #endif 58 66 59 67 #include "date_object.lut.h" … … 1054 1062 bool have_time = false; 1055 1063 1056 // for strtol error checking1057 errno = 0;1058 1059 1064 // Skip leading space 1060 1065 while(isspace(*dateString)) … … 1088 1093 1089 1094 // ' 09-Nov-99 23:12:40 GMT' 1095 errno = 0; 1090 1096 day = strtol(dateString, &newPosStr, 10); 1091 1097 if (errno) -
trunk/JavaScriptCore/kjs/date_object.h
r10084 r10456 25 25 #include "internal.h" 26 26 #include "function_object.h" 27 28 #include <sys/time.h>29 27 30 28 namespace KJS { -
trunk/JavaScriptCore/kjs/dtoa.cpp
r2913 r10456 178 178 #define INFNAN_CHECK 179 179 #include "dtoa.h" 180 #undef strtod /* do not remove: needed for WIN32 */ 180 181 #define strtod kjs_strtod 181 182 #define dtoa kjs_dtoa -
trunk/JavaScriptCore/kjs/fast_malloc.cpp
r10447 r10456 227 227 #include "fast_malloc.h" 228 228 229 #define MALLOC_FAILURE_ACTION abort() 230 231 #if !WIN32 229 232 #define MORECORE_CONTIGUOUS 0 230 233 #define MORECORE_CANNOT_TRIM 1 231 # define MALLOC_FAILURE_ACTION abort()234 #endif 232 235 233 236 namespace KJS { … … 302 305 static long getpagesize(void); 303 306 static long getregionsize(void); 304 static void *sbrk( longsize);307 static void *sbrk(ptrdiff_t size); 305 308 static void *mmap(void *ptr, long size, long prot, long type, long handle, long arg); 306 309 static long munmap(void *ptr, long size); … … 5029 5032 /* Allocate and link a region entry in the region list */ 5030 5033 static int region_list_append (region_list_entry **last, void *base_reserved, long reserve_size) { 5031 region_list_entry *next = HeapAlloc (GetProcessHeap (), 0, sizeof (region_list_entry));5034 region_list_entry *next = (region_list_entry *) HeapAlloc (GetProcessHeap (), 0, sizeof (region_list_entry)); 5032 5035 if (! next) 5033 5036 return FALSE; … … 5058 5061 5059 5062 /* sbrk for windows */ 5060 static void *sbrk ( longsize) {5063 static void *sbrk (ptrdiff_t size) { 5061 5064 static long g_pagesize, g_my_pagesize; 5062 5065 static long g_regionsize, g_my_regionsize; … … 5064 5067 void *result = (void *) MORECORE_FAILURE; 5065 5068 #ifdef TRACE 5066 printf ("sbrk % d\n",size);5069 printf ("sbrk %ld\n", (long) size); 5067 5070 #endif 5068 5071 #if defined (USE_MALLOC_LOCK) && defined (NEEDED) -
trunk/JavaScriptCore/kjs/function.cpp
r10412 r10456 42 42 43 43 #include <unicode/uchar.h> 44 45 #if WIN32 46 // Define a locale-independent isxdigit. 47 #undef isxdigit 48 inline bool isxdigit(int c) { return _isctype(c, _HEX); } 49 #endif 44 50 45 51 using namespace KXMLCore; -
trunk/JavaScriptCore/kjs/function.h
r10399 r10456 37 37 */ 38 38 class FunctionImp : public InternalFunctionImp { 39 friend class Function;40 39 friend class ActivationImp; 41 40 public: -
trunk/JavaScriptCore/kjs/identifier.cpp
r10265 r10456 26 26 // runs at init time. 27 27 28 #if APPLE_CHANGES29 28 #define AVOID_STATIC_CONSTRUCTORS 1 30 #endif31 29 32 30 #if AVOID_STATIC_CONSTRUCTORS … … 37 35 38 36 #include "fast_malloc.h" 37 #include <string.h> // for strlen 39 38 40 39 #define DUMP_STATISTICS 0 … … 299 298 #if !AVOID_STATIC_CONSTRUCTORS 300 299 // Define an Identifier in the normal way. 301 #define DEFINE_GLOBAL(name, string) extern const Identifier name ## PropertyName(string);300 #define DEFINE_GLOBAL(name, string) extern const Identifier name(string); 302 301 #else 303 302 // Define an Identifier-sized array of pointers to avoid static initialization. -
trunk/JavaScriptCore/kjs/internal.cpp
r10399 r10456 26 26 #include <math.h> 27 27 #include <assert.h> 28 #ifndef NDEBUG29 #include <strings.h> // for strdup30 #endif31 28 32 29 #include "array_object.h" … … 50 47 #include "string_object.h" 51 48 52 #define I18N_NOOP(s) s 49 #if WIN32 50 #include <float.h> 51 #define copysign(a, b) _copysign(a, b) 52 #endif 53 53 54 54 extern int kjsyyparse(); … … 59 59 60 60 #if !APPLE_CHANGES 61 61 62 62 #ifdef WORDS_BIGENDIAN 63 63 const unsigned char NaN_Bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }; … … 70 70 const unsigned char Inf_Bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; 71 71 #endif 72 72 73 73 const double NaN = *(const double*) NaN_Bytes; 74 74 const double Inf = *(const double*) Inf_Bytes; 75 75 76 76 #endif // APPLE_CHANGES 77 78 #if !KJS_MULTIPLE_THREADS 79 80 static inline void initializeInterpreterLock() { } 81 static inline void lockInterpreter() { } 82 static inline void unlockInterpreter() { } 83 84 const int interpreterLockCount = 1; 85 86 #else 77 87 78 88 static pthread_once_t interpreterLockOnce = PTHREAD_ONCE_INIT; … … 104 114 } 105 115 106 116 #endif 107 117 108 118 // ------------------------------ UndefinedImp --------------------------------- -
trunk/JavaScriptCore/kjs/internal.h
r10399 r10456 35 35 #include "shared_ptr.h" 36 36 37 #if !WIN32 38 #define KJS_MULTIPLE_THREADS 1 39 #endif 40 37 41 #define I18N_NOOP(s) s 38 42 -
trunk/JavaScriptCore/kjs/interpreter_map.cpp
r9768 r10456 22 22 #include "interpreter_map.h" 23 23 #include "pointer_hash.h" 24 #include <stdlib.h> 24 25 25 26 namespace KJS { … … 31 32 int InterpreterMap::_tableSizeMask; 32 33 int InterpreterMap::_keyCount; 33 34 34 35 35 InterpreterImp * InterpreterMap::getInterpreterForGlobalObject(ObjectImp *global) … … 54 54 return 0; 55 55 } 56 57 56 58 57 void InterpreterMap::setInterpreterForGlobalObject(InterpreterImp *interpreter, ObjectImp *global) … … 172 171 } 173 172 174 175 173 } // namespace -
trunk/JavaScriptCore/kjs/list.cpp
r10181 r10456 23 23 24 24 #include "internal.h" 25 #include <algorithm> 25 26 26 27 #define DUMP_STATISTICS 0 28 29 using std::min; 27 30 28 31 namespace KJS { … … 97 100 #endif 98 101 99 100 102 inline void ListImp::markValues() 101 103 { 102 int inlineSize = MIN(size, inlineValuesSize);104 int inlineSize = min(size, inlineValuesSize); 103 105 for (int i = 0; i != inlineSize; ++i) { 104 106 if (!values[i]->marked()) { … … 291 293 int size = imp->size; 292 294 293 int inlineSize = MIN(size, inlineValuesSize);295 int inlineSize = min(size, inlineValuesSize); 294 296 for (int i = 0; i != inlineSize; ++i) 295 297 copy.append(imp->values[i]); … … 312 314 int size = imp->size; 313 315 314 int inlineSize = MIN(size, inlineValuesSize);316 int inlineSize = min(size, inlineValuesSize); 315 317 for (int i = 1; i < inlineSize; ++i) 316 318 copy.append(imp->values[i]); -
trunk/JavaScriptCore/kjs/math_object.cpp
r10084 r10456 32 32 33 33 #include "math_object.lut.h" 34 35 #if WIN32 36 37 #include <float.h> 38 static int signbit(double d) 39 { 40 // FIXME: Not sure if this is exactly right. 41 switch (_fpclass(d)) { 42 case _FPCLASS_NINF: 43 case _FPCLASS_NN: 44 case _FPCLASS_ND: 45 case _FPCLASS_NZ: 46 // It's one of wacky negatives, report as negative. 47 return 1; 48 case _FPCLASS_PINF: 49 case _FPCLASS_PN: 50 case _FPCLASS_PD: 51 case _FPCLASS_PZ: 52 // It's one of wacky positives, report as positive. 53 return 0; 54 default: 55 return d < 0; 56 } 57 } 58 59 #endif 34 60 35 61 #ifndef M_PI -
trunk/JavaScriptCore/kjs/nodes.cpp
r10416 r10456 119 119 fprintf( stderr, "Node::finalCheck(): list count : %d\n", (int)s_nodes.size() ); 120 120 std::list<Node *>::iterator it = s_nodes->begin(); 121 for ( u inti = 0; it != s_nodes->end() ; ++it, ++i )121 for ( unsigned i = 0; it != s_nodes->end() ; ++it, ++i ) 122 122 fprintf( stderr, "[%d] Still having node %p (%s) (refcount %d)\n", i, (void*)*it, typeid( **it ).name(), (*it)->refcount ); 123 123 delete s_nodes; … … 1031 1031 // ECMA 11.13 1032 1032 1033 #if __GNUC__ 1033 1034 // gcc refuses to inline this without the always_inline, but inlining it does help 1034 1035 static inline ValueImp *valueForReadModifyAssignment(ExecState * exec, ValueImp *v1, ValueImp *v2, Operator oper) __attribute__((always_inline)); 1036 #endif 1035 1037 1036 1038 static inline ValueImp *valueForReadModifyAssignment(ExecState * exec, ValueImp *v1, ValueImp *v2, Operator oper) -
trunk/JavaScriptCore/kjs/number_object.cpp
r10207 r10456 174 174 } 175 175 176 if (x >= pow(10 ,21))176 if (x >= pow(10.0, 21.0)) 177 177 return String(s+UString::from(x)); 178 178 179 double n = floor(x*pow(10 ,f));180 if (fabs(n /pow(10,f)-x) > fabs((n+1)/pow(10,f)-x))179 double n = floor(x*pow(10.0, f)); 180 if (fabs(n / pow(10.0, f) - x) > fabs((n + 1) / pow(10.0, f) - x)) 181 181 n++; 182 182 … … 212 212 if (!fractionDigits->isUndefined()) { 213 213 double logx = floor(log10(x)); 214 x /= pow(10 ,logx);215 double fx = floor(x *pow(10,f))/pow(10,f);216 double cx = ceil(x *pow(10,f))/pow(10,f);214 x /= pow(10.0, logx); 215 double fx = floor(x * pow(10.0, f)) / pow(10.0,f); 216 double cx = ceil(x * pow(10.0, f)) / pow(10.0, f); 217 217 218 218 if (fabs(fx-x) < fabs(cx-x)) … … 309 309 if (x != 0) { 310 310 e = int(log10(x)); 311 double n = floor(x /pow(10,e-p+1));312 if (n < pow(10 ,p-1)) {311 double n = floor(x / pow(10.0, e - p + 1)); 312 if (n < pow(10.0, p - 1)) { 313 313 e = e - 1; 314 n = floor(x /pow(10,e-p+1));315 } 316 317 if (fabs((n +1)*pow(10,e-p+1)-x) < fabs(n*pow(10,e-p+1)-x))314 n = floor(x / pow(10.0, e - p + 1)); 315 } 316 317 if (fabs((n + 1) * pow(10.0, e - p + 1) - x) < fabs(n * pow(10.0, e - p + 1) - x)) 318 318 n++; 319 assert(pow(10 ,p-1) <= n);320 assert(n < pow(10 ,p));319 assert(pow(10.0, p - 1) <= n); 320 assert(n < pow(10.0, p)); 321 321 322 322 m = integer_part_noexp(n); -
trunk/JavaScriptCore/kjs/operations.cpp
r10412 r10456 21 21 */ 22 22 23 #ifdef HAVE_CONFIG_H 23 #include "operations.h" 24 24 25 #include "config.h" 25 #endif26 26 27 27 #include <stdio.h> … … 40 40 #endif 41 41 42 #include "operations.h"43 42 #include "object.h" 44 43 45 using namespace KJS; 44 namespace KJS { 46 45 47 46 #if !APPLE_CHANGES 48 47 49 bool KJS::isNaN(double d)48 bool isNaN(double d) 50 49 { 51 50 #ifdef HAVE_FUNC_ISNAN … … 58 57 } 59 58 60 bool KJS::isInf(double d) 61 { 62 #if defined(HAVE_FUNC_ISINF) 59 bool isInf(double d) 60 { 61 #if WIN32 62 int fpClass = _fpclass(d); 63 return _FPCLASS_PINF == fpClass || _FPCLASS_NINF == fpClass; 64 #elif defined(HAVE_FUNC_ISINF) 63 65 return isinf(d); 64 66 #elif HAVE_FUNC_FINITE … … 71 73 } 72 74 73 bool KJS::isPosInf(double d) 74 { 75 #if APPLE_CHANGES 76 return isinf(d) && d > 0; 77 #else 78 #if defined(HAVE_FUNC_ISINF) 75 bool isPosInf(double d) 76 { 77 #if WIN32 78 return _FPCLASS_PINF == _fpclass(d); 79 #elif defined(HAVE_FUNC_ISINF) 79 80 return (isinf(d) == 1); 80 81 #elif HAVE_FUNC_FINITE … … 85 86 return false; 86 87 #endif 87 #endif 88 } 89 90 bool KJS::isNegInf(double d) 91 { 92 #if APPLE_CHANGES 93 return isinf(d) && d < 0; 94 #else 95 #if defined(HAVE_FUNC_ISINF) 88 } 89 90 bool isNegInf(double d) 91 { 92 #if WIN32 93 return _FPCLASS_PINF == _fpclass(d); 94 #elif defined(HAVE_FUNC_ISINF) 96 95 return (isinf(d) == -1); 97 96 #elif HAVE_FUNC_FINITE … … 102 101 return false; 103 102 #endif 104 #endif105 103 } 106 104 … … 108 106 109 107 // ECMA 11.9.3 110 bool KJS::equal(ExecState *exec, ValueImp *v1, ValueImp *v2)108 bool equal(ExecState *exec, ValueImp *v1, ValueImp *v2) 111 109 { 112 110 Type t1 = v1->type(); … … 162 160 } 163 161 164 bool KJS::strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2)162 bool strictEqual(ExecState *exec, ValueImp *v1, ValueImp *v2) 165 163 { 166 164 Type t1 = v1->type(); … … 194 192 } 195 193 196 int KJS::relation(ExecState *exec, ValueImp *v1, ValueImp *v2)194 int relation(ExecState *exec, ValueImp *v1, ValueImp *v2) 197 195 { 198 196 ValueImp *p1 = v1->toPrimitive(exec,NumberType); … … 211 209 } 212 210 213 int KJS::maxInt(int d1, int d2)211 int maxInt(int d1, int d2) 214 212 { 215 213 return (d1 > d2) ? d1 : d2; 216 214 } 217 215 218 int KJS::minInt(int d1, int d2)216 int minInt(int d1, int d2) 219 217 { 220 218 return (d1 < d2) ? d1 : d2; … … 222 220 223 221 // ECMA 11.6 224 ValueImp * KJS::add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)222 ValueImp *add(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper) 225 223 { 226 224 // exception for the Date exception in defaultValue() … … 247 245 248 246 // ECMA 11.5 249 ValueImp * KJS::mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper)247 ValueImp *mult(ExecState *exec, ValueImp *v1, ValueImp *v2, char oper) 250 248 { 251 249 bool n1KnownToBeInteger; … … 270 268 return jsNumber(result, resultKnownToBeInteger); 271 269 } 270 271 } -
trunk/JavaScriptCore/kjs/regexp.cpp
r9768 r10456 142 142 #else 143 143 144 const u intmaxMatch = 10;144 const unsigned maxMatch = 10; 145 145 regmatch_t rmatch[maxMatch]; 146 146 … … 159 159 // map rmatch array to ovector used in PCRE case 160 160 _numSubPatterns = 0; 161 for(u intj = 1; j < maxMatch && rmatch[j].rm_so >= 0 ; j++)161 for(unsigned j = 1; j < maxMatch && rmatch[j].rm_so >= 0 ; j++) 162 162 _numSubPatterns++; 163 163 int ovecsize = (_numSubPatterns+1)*3; // see above 164 164 *ovector = new int[ovecsize]; 165 for (u intj = 0; j < _numSubPatterns + 1; j++) {165 for (unsigned j = 0; j < _numSubPatterns + 1; j++) { 166 166 if (j>maxMatch) 167 167 break; -
trunk/JavaScriptCore/kjs/regexp.h
r9768 r10456 49 49 50 50 UString match(const UString &s, int i, int *pos = 0, int **ovector = 0); 51 u intsubPatterns() const { return _numSubPatterns; }51 unsigned subPatterns() const { return _numSubPatterns; } 52 52 53 53 private: … … 58 58 #endif 59 59 int _flags; 60 u int_numSubPatterns;60 unsigned _numSubPatterns; 61 61 62 62 RegExp(const RegExp &); -
trunk/JavaScriptCore/kjs/regexp_object.cpp
r10207 r10456 196 196 list.append(String(result)); 197 197 if ( lastOvector ) 198 for ( u inti = 1 ; i < lastNrSubPatterns + 1 ; ++i )198 for ( unsigned i = 1 ; i < lastNrSubPatterns + 1 ; ++i ) 199 199 { 200 200 int start = lastOvector[2*i]; -
trunk/JavaScriptCore/kjs/regexp_object.h
r10084 r10456 84 84 UString lastString; 85 85 int *lastOvector; 86 u intlastNrSubPatterns;86 unsigned lastNrSubPatterns; 87 87 }; 88 88
Note:
See TracChangeset
for help on using the changeset viewer.