OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 406 |
407 static Object* Runtime_ClassOf(Arguments args) { | 407 static Object* Runtime_ClassOf(Arguments args) { |
408 NoHandleAllocation ha; | 408 NoHandleAllocation ha; |
409 ASSERT(args.length() == 1); | 409 ASSERT(args.length() == 1); |
410 Object* obj = args[0]; | 410 Object* obj = args[0]; |
411 if (!obj->IsJSObject()) return Heap::null_value(); | 411 if (!obj->IsJSObject()) return Heap::null_value(); |
412 return JSObject::cast(obj)->class_name(); | 412 return JSObject::cast(obj)->class_name(); |
413 } | 413 } |
414 | 414 |
415 | 415 |
416 static Object* Runtime_HasStringClass(Arguments args) { | |
417 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::String_symbol())); | |
418 } | |
419 | |
420 | |
421 static Object* Runtime_HasDateClass(Arguments args) { | |
422 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Date_symbol())); | |
423 } | |
424 | |
425 | |
426 static Object* Runtime_HasArrayClass(Arguments args) { | |
427 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Array_symbol())); | |
428 } | |
429 | |
430 | |
431 static Object* Runtime_HasFunctionClass(Arguments args) { | |
432 return Heap::ToBoolean( | |
433 args[0]->HasSpecificClassOf(Heap::function_class_symbol())); | |
434 } | |
435 | |
436 | |
437 static Object* Runtime_HasNumberClass(Arguments args) { | |
438 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Number_symbol())); | |
439 } | |
440 | |
441 | |
442 static Object* Runtime_HasBooleanClass(Arguments args) { | |
443 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::Boolean_symbol())); | |
444 } | |
445 | |
446 | |
447 static Object* Runtime_HasArgumentsClass(Arguments args) { | |
448 return Heap::ToBoolean( | |
449 args[0]->HasSpecificClassOf(Heap::Arguments_symbol())); | |
450 } | |
451 | |
452 | |
453 static Object* Runtime_HasRegExpClass(Arguments args) { | |
454 return Heap::ToBoolean(args[0]->HasSpecificClassOf(Heap::RegExp_symbol())); | |
455 } | |
456 | |
457 | |
458 static Object* Runtime_IsInPrototypeChain(Arguments args) { | 416 static Object* Runtime_IsInPrototypeChain(Arguments args) { |
459 NoHandleAllocation ha; | 417 NoHandleAllocation ha; |
460 ASSERT(args.length() == 2); | 418 ASSERT(args.length() == 2); |
461 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 419 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
462 Object* O = args[0]; | 420 Object* O = args[0]; |
463 Object* V = args[1]; | 421 Object* V = args[1]; |
464 while (true) { | 422 while (true) { |
465 Object* prototype = V->GetPrototype(); | 423 Object* prototype = V->GetPrototype(); |
466 if (prototype->IsNull()) return Heap::false_value(); | 424 if (prototype->IsNull()) return Heap::false_value(); |
467 if (O == prototype) return Heap::true_value(); | 425 if (O == prototype) return Heap::true_value(); |
(...skipping 7032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7500 } else { | 7458 } else { |
7501 // Handle last resort GC and make sure to allow future allocations | 7459 // Handle last resort GC and make sure to allow future allocations |
7502 // to grow the heap without causing GCs (if possible). | 7460 // to grow the heap without causing GCs (if possible). |
7503 Counters::gc_last_resort_from_js.Increment(); | 7461 Counters::gc_last_resort_from_js.Increment(); |
7504 Heap::CollectAllGarbage(); | 7462 Heap::CollectAllGarbage(); |
7505 } | 7463 } |
7506 } | 7464 } |
7507 | 7465 |
7508 | 7466 |
7509 } } // namespace v8::internal | 7467 } } // namespace v8::internal |
OLD | NEW |