OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 break; | 217 break; |
218 } | 218 } |
219 default: | 219 default: |
220 UNREACHABLE(); | 220 UNREACHABLE(); |
221 break; | 221 break; |
222 } | 222 } |
223 return copy; | 223 return copy; |
224 } | 224 } |
225 | 225 |
226 | 226 |
227 static MaybeObject* Runtime_CloneLiteralBoilerplate( | 227 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneLiteralBoilerplate) { |
228 RUNTIME_CALLING_CONVENTION) { | |
229 RUNTIME_GET_ISOLATE; | |
230 CONVERT_CHECKED(JSObject, boilerplate, args[0]); | 228 CONVERT_CHECKED(JSObject, boilerplate, args[0]); |
231 return DeepCopyBoilerplate(isolate, boilerplate); | 229 return DeepCopyBoilerplate(isolate, boilerplate); |
232 } | 230 } |
233 | 231 |
234 | 232 |
235 static MaybeObject* Runtime_CloneShallowLiteralBoilerplate( | 233 RUNTIME_FUNCTION(MaybeObject*, Runtime_CloneShallowLiteralBoilerplate) { |
236 RUNTIME_CALLING_CONVENTION) { | |
237 RUNTIME_GET_ISOLATE; | |
238 CONVERT_CHECKED(JSObject, boilerplate, args[0]); | 234 CONVERT_CHECKED(JSObject, boilerplate, args[0]); |
239 return isolate->heap()->CopyJSObject(boilerplate); | 235 return isolate->heap()->CopyJSObject(boilerplate); |
240 } | 236 } |
241 | 237 |
242 | 238 |
243 static Handle<Map> ComputeObjectLiteralMap( | 239 static Handle<Map> ComputeObjectLiteralMap( |
244 Handle<Context> context, | 240 Handle<Context> context, |
245 Handle<FixedArray> constant_properties, | 241 Handle<FixedArray> constant_properties, |
246 bool* is_result_from_cache) { | 242 bool* is_result_from_cache) { |
247 Isolate* isolate = context->GetIsolate(); | 243 Isolate* isolate = context->GetIsolate(); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 kHasNoFunctionLiteral); | 464 kHasNoFunctionLiteral); |
469 case CompileTimeValue::ARRAY_LITERAL: | 465 case CompileTimeValue::ARRAY_LITERAL: |
470 return CreateArrayLiteralBoilerplate(isolate, literals, elements); | 466 return CreateArrayLiteralBoilerplate(isolate, literals, elements); |
471 default: | 467 default: |
472 UNREACHABLE(); | 468 UNREACHABLE(); |
473 return Handle<Object>::null(); | 469 return Handle<Object>::null(); |
474 } | 470 } |
475 } | 471 } |
476 | 472 |
477 | 473 |
478 static MaybeObject* Runtime_CreateArrayLiteralBoilerplate( | 474 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralBoilerplate) { |
479 RUNTIME_CALLING_CONVENTION) { | |
480 RUNTIME_GET_ISOLATE; | |
481 // Takes a FixedArray of elements containing the literal elements of | 475 // Takes a FixedArray of elements containing the literal elements of |
482 // the array literal and produces JSArray with those elements. | 476 // the array literal and produces JSArray with those elements. |
483 // Additionally takes the literals array of the surrounding function | 477 // Additionally takes the literals array of the surrounding function |
484 // which contains the context from which to get the Array function | 478 // which contains the context from which to get the Array function |
485 // to use for creating the array literal. | 479 // to use for creating the array literal. |
486 HandleScope scope(isolate); | 480 HandleScope scope(isolate); |
487 ASSERT(args.length() == 3); | 481 ASSERT(args.length() == 3); |
488 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 482 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
489 CONVERT_SMI_CHECKED(literals_index, args[1]); | 483 CONVERT_SMI_CHECKED(literals_index, args[1]); |
490 CONVERT_ARG_CHECKED(FixedArray, elements, 2); | 484 CONVERT_ARG_CHECKED(FixedArray, elements, 2); |
491 | 485 |
492 Handle<Object> object = | 486 Handle<Object> object = |
493 CreateArrayLiteralBoilerplate(isolate, literals, elements); | 487 CreateArrayLiteralBoilerplate(isolate, literals, elements); |
494 if (object.is_null()) return Failure::Exception(); | 488 if (object.is_null()) return Failure::Exception(); |
495 | 489 |
496 // Update the functions literal and return the boilerplate. | 490 // Update the functions literal and return the boilerplate. |
497 literals->set(literals_index, *object); | 491 literals->set(literals_index, *object); |
498 return *object; | 492 return *object; |
499 } | 493 } |
500 | 494 |
501 | 495 |
502 static MaybeObject* Runtime_CreateObjectLiteral(RUNTIME_CALLING_CONVENTION) { | 496 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteral) { |
503 RUNTIME_GET_ISOLATE; | |
504 HandleScope scope(isolate); | 497 HandleScope scope(isolate); |
505 ASSERT(args.length() == 4); | 498 ASSERT(args.length() == 4); |
506 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 499 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
507 CONVERT_SMI_CHECKED(literals_index, args[1]); | 500 CONVERT_SMI_CHECKED(literals_index, args[1]); |
508 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); | 501 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); |
509 CONVERT_SMI_CHECKED(flags, args[3]); | 502 CONVERT_SMI_CHECKED(flags, args[3]); |
510 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 503 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
511 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 504 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
512 | 505 |
513 // Check if boilerplate exists. If not, create it first. | 506 // Check if boilerplate exists. If not, create it first. |
514 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 507 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
515 if (*boilerplate == isolate->heap()->undefined_value()) { | 508 if (*boilerplate == isolate->heap()->undefined_value()) { |
516 boilerplate = CreateObjectLiteralBoilerplate(isolate, | 509 boilerplate = CreateObjectLiteralBoilerplate(isolate, |
517 literals, | 510 literals, |
518 constant_properties, | 511 constant_properties, |
519 should_have_fast_elements, | 512 should_have_fast_elements, |
520 has_function_literal); | 513 has_function_literal); |
521 if (boilerplate.is_null()) return Failure::Exception(); | 514 if (boilerplate.is_null()) return Failure::Exception(); |
522 // Update the functions literal and return the boilerplate. | 515 // Update the functions literal and return the boilerplate. |
523 literals->set(literals_index, *boilerplate); | 516 literals->set(literals_index, *boilerplate); |
524 } | 517 } |
525 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); | 518 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); |
526 } | 519 } |
527 | 520 |
528 | 521 |
529 static MaybeObject* Runtime_CreateObjectLiteralShallow( | 522 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectLiteralShallow) { |
530 RUNTIME_CALLING_CONVENTION) { | |
531 RUNTIME_GET_ISOLATE; | |
532 HandleScope scope(isolate); | 523 HandleScope scope(isolate); |
533 ASSERT(args.length() == 4); | 524 ASSERT(args.length() == 4); |
534 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 525 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
535 CONVERT_SMI_CHECKED(literals_index, args[1]); | 526 CONVERT_SMI_CHECKED(literals_index, args[1]); |
536 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); | 527 CONVERT_ARG_CHECKED(FixedArray, constant_properties, 2); |
537 CONVERT_SMI_CHECKED(flags, args[3]); | 528 CONVERT_SMI_CHECKED(flags, args[3]); |
538 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 529 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
539 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 530 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
540 | 531 |
541 // Check if boilerplate exists. If not, create it first. | 532 // Check if boilerplate exists. If not, create it first. |
542 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 533 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
543 if (*boilerplate == isolate->heap()->undefined_value()) { | 534 if (*boilerplate == isolate->heap()->undefined_value()) { |
544 boilerplate = CreateObjectLiteralBoilerplate(isolate, | 535 boilerplate = CreateObjectLiteralBoilerplate(isolate, |
545 literals, | 536 literals, |
546 constant_properties, | 537 constant_properties, |
547 should_have_fast_elements, | 538 should_have_fast_elements, |
548 has_function_literal); | 539 has_function_literal); |
549 if (boilerplate.is_null()) return Failure::Exception(); | 540 if (boilerplate.is_null()) return Failure::Exception(); |
550 // Update the functions literal and return the boilerplate. | 541 // Update the functions literal and return the boilerplate. |
551 literals->set(literals_index, *boilerplate); | 542 literals->set(literals_index, *boilerplate); |
552 } | 543 } |
553 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); | 544 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); |
554 } | 545 } |
555 | 546 |
556 | 547 |
557 static MaybeObject* Runtime_CreateArrayLiteral(RUNTIME_CALLING_CONVENTION) { | 548 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteral) { |
558 RUNTIME_GET_ISOLATE; | |
559 HandleScope scope(isolate); | 549 HandleScope scope(isolate); |
560 ASSERT(args.length() == 3); | 550 ASSERT(args.length() == 3); |
561 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 551 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
562 CONVERT_SMI_CHECKED(literals_index, args[1]); | 552 CONVERT_SMI_CHECKED(literals_index, args[1]); |
563 CONVERT_ARG_CHECKED(FixedArray, elements, 2); | 553 CONVERT_ARG_CHECKED(FixedArray, elements, 2); |
564 | 554 |
565 // Check if boilerplate exists. If not, create it first. | 555 // Check if boilerplate exists. If not, create it first. |
566 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 556 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
567 if (*boilerplate == isolate->heap()->undefined_value()) { | 557 if (*boilerplate == isolate->heap()->undefined_value()) { |
568 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); | 558 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); |
569 if (boilerplate.is_null()) return Failure::Exception(); | 559 if (boilerplate.is_null()) return Failure::Exception(); |
570 // Update the functions literal and return the boilerplate. | 560 // Update the functions literal and return the boilerplate. |
571 literals->set(literals_index, *boilerplate); | 561 literals->set(literals_index, *boilerplate); |
572 } | 562 } |
573 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); | 563 return DeepCopyBoilerplate(isolate, JSObject::cast(*boilerplate)); |
574 } | 564 } |
575 | 565 |
576 | 566 |
577 static MaybeObject* Runtime_CreateArrayLiteralShallow( | 567 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { |
578 RUNTIME_CALLING_CONVENTION) { | |
579 RUNTIME_GET_ISOLATE; | |
580 HandleScope scope(isolate); | 568 HandleScope scope(isolate); |
581 ASSERT(args.length() == 3); | 569 ASSERT(args.length() == 3); |
582 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 570 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
583 CONVERT_SMI_CHECKED(literals_index, args[1]); | 571 CONVERT_SMI_CHECKED(literals_index, args[1]); |
584 CONVERT_ARG_CHECKED(FixedArray, elements, 2); | 572 CONVERT_ARG_CHECKED(FixedArray, elements, 2); |
585 | 573 |
586 // Check if boilerplate exists. If not, create it first. | 574 // Check if boilerplate exists. If not, create it first. |
587 Handle<Object> boilerplate(literals->get(literals_index), isolate); | 575 Handle<Object> boilerplate(literals->get(literals_index), isolate); |
588 if (*boilerplate == isolate->heap()->undefined_value()) { | 576 if (*boilerplate == isolate->heap()->undefined_value()) { |
589 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); | 577 boilerplate = CreateArrayLiteralBoilerplate(isolate, literals, elements); |
590 if (boilerplate.is_null()) return Failure::Exception(); | 578 if (boilerplate.is_null()) return Failure::Exception(); |
591 // Update the functions literal and return the boilerplate. | 579 // Update the functions literal and return the boilerplate. |
592 literals->set(literals_index, *boilerplate); | 580 literals->set(literals_index, *boilerplate); |
593 } | 581 } |
594 if (JSObject::cast(*boilerplate)->elements()->map() == | 582 if (JSObject::cast(*boilerplate)->elements()->map() == |
595 isolate->heap()->fixed_cow_array_map()) { | 583 isolate->heap()->fixed_cow_array_map()) { |
596 isolate->counters()->cow_arrays_created_runtime()->Increment(); | 584 isolate->counters()->cow_arrays_created_runtime()->Increment(); |
597 } | 585 } |
598 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); | 586 return isolate->heap()->CopyJSObject(JSObject::cast(*boilerplate)); |
599 } | 587 } |
600 | 588 |
601 | 589 |
602 static MaybeObject* Runtime_CreateCatchExtensionObject( | 590 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCatchExtensionObject) { |
603 RUNTIME_CALLING_CONVENTION) { | |
604 RUNTIME_GET_ISOLATE; | |
605 ASSERT(args.length() == 2); | 591 ASSERT(args.length() == 2); |
606 CONVERT_CHECKED(String, key, args[0]); | 592 CONVERT_CHECKED(String, key, args[0]); |
607 Object* value = args[1]; | 593 Object* value = args[1]; |
608 // Create a catch context extension object. | 594 // Create a catch context extension object. |
609 JSFunction* constructor = | 595 JSFunction* constructor = |
610 isolate->context()->global_context()-> | 596 isolate->context()->global_context()-> |
611 context_extension_function(); | 597 context_extension_function(); |
612 Object* object; | 598 Object* object; |
613 { MaybeObject* maybe_object = isolate->heap()->AllocateJSObject(constructor); | 599 { MaybeObject* maybe_object = isolate->heap()->AllocateJSObject(constructor); |
614 if (!maybe_object->ToObject(&object)) return maybe_object; | 600 if (!maybe_object->ToObject(&object)) return maybe_object; |
615 } | 601 } |
616 // Assign the exception value to the catch variable and make sure | 602 // Assign the exception value to the catch variable and make sure |
617 // that the catch variable is DontDelete. | 603 // that the catch variable is DontDelete. |
618 { MaybeObject* maybe_value = | 604 { MaybeObject* maybe_value = |
619 // Passing non-strict per ECMA-262 5th Ed. 12.14. Catch, bullet #4. | 605 // Passing non-strict per ECMA-262 5th Ed. 12.14. Catch, bullet #4. |
620 JSObject::cast(object)->SetProperty( | 606 JSObject::cast(object)->SetProperty( |
621 key, value, DONT_DELETE, kNonStrictMode); | 607 key, value, DONT_DELETE, kNonStrictMode); |
622 if (!maybe_value->ToObject(&value)) return maybe_value; | 608 if (!maybe_value->ToObject(&value)) return maybe_value; |
623 } | 609 } |
624 return object; | 610 return object; |
625 } | 611 } |
626 | 612 |
627 | 613 |
628 static MaybeObject* Runtime_ClassOf(RUNTIME_CALLING_CONVENTION) { | 614 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
629 RUNTIME_GET_ISOLATE; | |
630 NoHandleAllocation ha; | 615 NoHandleAllocation ha; |
631 ASSERT(args.length() == 1); | 616 ASSERT(args.length() == 1); |
632 Object* obj = args[0]; | 617 Object* obj = args[0]; |
633 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 618 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
634 return JSObject::cast(obj)->class_name(); | 619 return JSObject::cast(obj)->class_name(); |
635 } | 620 } |
636 | 621 |
637 | 622 |
638 static MaybeObject* Runtime_IsInPrototypeChain(RUNTIME_CALLING_CONVENTION) { | 623 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { |
639 RUNTIME_GET_ISOLATE; | |
640 NoHandleAllocation ha; | 624 NoHandleAllocation ha; |
641 ASSERT(args.length() == 2); | 625 ASSERT(args.length() == 2); |
642 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 626 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
643 Object* O = args[0]; | 627 Object* O = args[0]; |
644 Object* V = args[1]; | 628 Object* V = args[1]; |
645 while (true) { | 629 while (true) { |
646 Object* prototype = V->GetPrototype(); | 630 Object* prototype = V->GetPrototype(); |
647 if (prototype->IsNull()) return isolate->heap()->false_value(); | 631 if (prototype->IsNull()) return isolate->heap()->false_value(); |
648 if (O == prototype) return isolate->heap()->true_value(); | 632 if (O == prototype) return isolate->heap()->true_value(); |
649 V = prototype; | 633 V = prototype; |
650 } | 634 } |
651 } | 635 } |
652 | 636 |
653 | 637 |
654 // Inserts an object as the hidden prototype of another object. | 638 // Inserts an object as the hidden prototype of another object. |
655 static MaybeObject* Runtime_SetHiddenPrototype(RUNTIME_CALLING_CONVENTION) { | 639 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenPrototype) { |
656 RUNTIME_GET_ISOLATE; | |
657 NoHandleAllocation ha; | 640 NoHandleAllocation ha; |
658 ASSERT(args.length() == 2); | 641 ASSERT(args.length() == 2); |
659 CONVERT_CHECKED(JSObject, jsobject, args[0]); | 642 CONVERT_CHECKED(JSObject, jsobject, args[0]); |
660 CONVERT_CHECKED(JSObject, proto, args[1]); | 643 CONVERT_CHECKED(JSObject, proto, args[1]); |
661 | 644 |
662 // Sanity checks. The old prototype (that we are replacing) could | 645 // Sanity checks. The old prototype (that we are replacing) could |
663 // theoretically be null, but if it is not null then check that we | 646 // theoretically be null, but if it is not null then check that we |
664 // didn't already install a hidden prototype here. | 647 // didn't already install a hidden prototype here. |
665 RUNTIME_ASSERT(!jsobject->GetPrototype()->IsHeapObject() || | 648 RUNTIME_ASSERT(!jsobject->GetPrototype()->IsHeapObject() || |
666 !HeapObject::cast(jsobject->GetPrototype())->map()->is_hidden_prototype()); | 649 !HeapObject::cast(jsobject->GetPrototype())->map()->is_hidden_prototype()); |
(...skipping 21 matching lines...) Expand all Loading... |
688 new_proto_map->set_is_hidden_prototype(); | 671 new_proto_map->set_is_hidden_prototype(); |
689 | 672 |
690 // Set the object's prototype to proto. | 673 // Set the object's prototype to proto. |
691 new_map->set_prototype(proto); | 674 new_map->set_prototype(proto); |
692 jsobject->set_map(new_map); | 675 jsobject->set_map(new_map); |
693 | 676 |
694 return isolate->heap()->undefined_value(); | 677 return isolate->heap()->undefined_value(); |
695 } | 678 } |
696 | 679 |
697 | 680 |
698 static MaybeObject* Runtime_IsConstructCall(RUNTIME_CALLING_CONVENTION) { | 681 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConstructCall) { |
699 RUNTIME_GET_ISOLATE; | |
700 NoHandleAllocation ha; | 682 NoHandleAllocation ha; |
701 ASSERT(args.length() == 0); | 683 ASSERT(args.length() == 0); |
702 JavaScriptFrameIterator it; | 684 JavaScriptFrameIterator it; |
703 return isolate->heap()->ToBoolean(it.frame()->IsConstructor()); | 685 return isolate->heap()->ToBoolean(it.frame()->IsConstructor()); |
704 } | 686 } |
705 | 687 |
706 | 688 |
707 // Recursively traverses hidden prototypes if property is not found | 689 // Recursively traverses hidden prototypes if property is not found |
708 static void GetOwnPropertyImplementation(JSObject* obj, | 690 static void GetOwnPropertyImplementation(JSObject* obj, |
709 String* name, | 691 String* name, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 DESCRIPTOR_SIZE | 799 DESCRIPTOR_SIZE |
818 }; | 800 }; |
819 | 801 |
820 // Returns an array with the property description: | 802 // Returns an array with the property description: |
821 // if args[1] is not a property on args[0] | 803 // if args[1] is not a property on args[0] |
822 // returns undefined | 804 // returns undefined |
823 // if args[1] is a data property on args[0] | 805 // if args[1] is a data property on args[0] |
824 // [false, value, Writeable, Enumerable, Configurable] | 806 // [false, value, Writeable, Enumerable, Configurable] |
825 // if args[1] is an accessor on args[0] | 807 // if args[1] is an accessor on args[0] |
826 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 808 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
827 static MaybeObject* Runtime_GetOwnProperty(RUNTIME_CALLING_CONVENTION) { | 809 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { |
828 RUNTIME_GET_ISOLATE; | |
829 ASSERT(args.length() == 2); | 810 ASSERT(args.length() == 2); |
830 Heap* heap = isolate->heap(); | 811 Heap* heap = isolate->heap(); |
831 HandleScope scope(isolate); | 812 HandleScope scope(isolate); |
832 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); | 813 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); |
833 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms); | 814 Handle<JSArray> desc = isolate->factory()->NewJSArrayWithElements(elms); |
834 LookupResult result; | 815 LookupResult result; |
835 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 816 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
836 CONVERT_ARG_CHECKED(String, name, 1); | 817 CONVERT_ARG_CHECKED(String, name, 1); |
837 | 818 |
838 // This could be an element. | 819 // This could be an element. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); | 936 { MaybeObject* maybe_value = obj->GetProperty(*obj, &result, *name, &attrs); |
956 if (!maybe_value->ToObject(&value)) return maybe_value; | 937 if (!maybe_value->ToObject(&value)) return maybe_value; |
957 } | 938 } |
958 elms->set(VALUE_INDEX, value); | 939 elms->set(VALUE_INDEX, value); |
959 } | 940 } |
960 | 941 |
961 return *desc; | 942 return *desc; |
962 } | 943 } |
963 | 944 |
964 | 945 |
965 static MaybeObject* Runtime_PreventExtensions(RUNTIME_CALLING_CONVENTION) { | 946 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { |
966 RUNTIME_GET_ISOLATE; | |
967 ASSERT(args.length() == 1); | 947 ASSERT(args.length() == 1); |
968 CONVERT_CHECKED(JSObject, obj, args[0]); | 948 CONVERT_CHECKED(JSObject, obj, args[0]); |
969 return obj->PreventExtensions(); | 949 return obj->PreventExtensions(); |
970 } | 950 } |
971 | 951 |
972 | 952 |
973 static MaybeObject* Runtime_IsExtensible(RUNTIME_CALLING_CONVENTION) { | 953 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { |
974 RUNTIME_GET_ISOLATE; | |
975 ASSERT(args.length() == 1); | 954 ASSERT(args.length() == 1); |
976 CONVERT_CHECKED(JSObject, obj, args[0]); | 955 CONVERT_CHECKED(JSObject, obj, args[0]); |
977 if (obj->IsJSGlobalProxy()) { | 956 if (obj->IsJSGlobalProxy()) { |
978 Object* proto = obj->GetPrototype(); | 957 Object* proto = obj->GetPrototype(); |
979 if (proto->IsNull()) return isolate->heap()->false_value(); | 958 if (proto->IsNull()) return isolate->heap()->false_value(); |
980 ASSERT(proto->IsJSGlobalObject()); | 959 ASSERT(proto->IsJSGlobalObject()); |
981 obj = JSObject::cast(proto); | 960 obj = JSObject::cast(proto); |
982 } | 961 } |
983 return obj->map()->is_extensible() ? isolate->heap()->true_value() | 962 return obj->map()->is_extensible() ? isolate->heap()->true_value() |
984 : isolate->heap()->false_value(); | 963 : isolate->heap()->false_value(); |
985 } | 964 } |
986 | 965 |
987 | 966 |
988 static MaybeObject* Runtime_RegExpCompile(RUNTIME_CALLING_CONVENTION) { | 967 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { |
989 RUNTIME_GET_ISOLATE; | |
990 HandleScope scope(isolate); | 968 HandleScope scope(isolate); |
991 ASSERT(args.length() == 3); | 969 ASSERT(args.length() == 3); |
992 CONVERT_ARG_CHECKED(JSRegExp, re, 0); | 970 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
993 CONVERT_ARG_CHECKED(String, pattern, 1); | 971 CONVERT_ARG_CHECKED(String, pattern, 1); |
994 CONVERT_ARG_CHECKED(String, flags, 2); | 972 CONVERT_ARG_CHECKED(String, flags, 2); |
995 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); | 973 Handle<Object> result = RegExpImpl::Compile(re, pattern, flags); |
996 if (result.is_null()) return Failure::Exception(); | 974 if (result.is_null()) return Failure::Exception(); |
997 return *result; | 975 return *result; |
998 } | 976 } |
999 | 977 |
1000 | 978 |
1001 static MaybeObject* Runtime_CreateApiFunction(RUNTIME_CALLING_CONVENTION) { | 979 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { |
1002 RUNTIME_GET_ISOLATE; | |
1003 HandleScope scope(isolate); | 980 HandleScope scope(isolate); |
1004 ASSERT(args.length() == 1); | 981 ASSERT(args.length() == 1); |
1005 CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0); | 982 CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0); |
1006 return *isolate->factory()->CreateApiFunction(data); | 983 return *isolate->factory()->CreateApiFunction(data); |
1007 } | 984 } |
1008 | 985 |
1009 | 986 |
1010 static MaybeObject* Runtime_IsTemplate(RUNTIME_CALLING_CONVENTION) { | 987 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { |
1011 RUNTIME_GET_ISOLATE; | |
1012 ASSERT(args.length() == 1); | 988 ASSERT(args.length() == 1); |
1013 Object* arg = args[0]; | 989 Object* arg = args[0]; |
1014 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 990 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
1015 return isolate->heap()->ToBoolean(result); | 991 return isolate->heap()->ToBoolean(result); |
1016 } | 992 } |
1017 | 993 |
1018 | 994 |
1019 static MaybeObject* Runtime_GetTemplateField(RUNTIME_CALLING_CONVENTION) { | 995 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { |
1020 RUNTIME_GET_ISOLATE; | |
1021 ASSERT(args.length() == 2); | 996 ASSERT(args.length() == 2); |
1022 CONVERT_CHECKED(HeapObject, templ, args[0]); | 997 CONVERT_CHECKED(HeapObject, templ, args[0]); |
1023 CONVERT_CHECKED(Smi, field, args[1]); | 998 CONVERT_CHECKED(Smi, field, args[1]); |
1024 int index = field->value(); | 999 int index = field->value(); |
1025 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 1000 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
1026 InstanceType type = templ->map()->instance_type(); | 1001 InstanceType type = templ->map()->instance_type(); |
1027 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 1002 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
1028 type == OBJECT_TEMPLATE_INFO_TYPE); | 1003 type == OBJECT_TEMPLATE_INFO_TYPE); |
1029 RUNTIME_ASSERT(offset > 0); | 1004 RUNTIME_ASSERT(offset > 0); |
1030 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 1005 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
1031 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 1006 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
1032 } else { | 1007 } else { |
1033 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 1008 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
1034 } | 1009 } |
1035 return *HeapObject::RawField(templ, offset); | 1010 return *HeapObject::RawField(templ, offset); |
1036 } | 1011 } |
1037 | 1012 |
1038 | 1013 |
1039 static MaybeObject* Runtime_DisableAccessChecks(RUNTIME_CALLING_CONVENTION) { | 1014 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { |
1040 RUNTIME_GET_ISOLATE; | |
1041 ASSERT(args.length() == 1); | 1015 ASSERT(args.length() == 1); |
1042 CONVERT_CHECKED(HeapObject, object, args[0]); | 1016 CONVERT_CHECKED(HeapObject, object, args[0]); |
1043 Map* old_map = object->map(); | 1017 Map* old_map = object->map(); |
1044 bool needs_access_checks = old_map->is_access_check_needed(); | 1018 bool needs_access_checks = old_map->is_access_check_needed(); |
1045 if (needs_access_checks) { | 1019 if (needs_access_checks) { |
1046 // Copy map so it won't interfere constructor's initial map. | 1020 // Copy map so it won't interfere constructor's initial map. |
1047 Object* new_map; | 1021 Object* new_map; |
1048 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1022 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
1049 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1023 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1050 } | 1024 } |
1051 | 1025 |
1052 Map::cast(new_map)->set_is_access_check_needed(false); | 1026 Map::cast(new_map)->set_is_access_check_needed(false); |
1053 object->set_map(Map::cast(new_map)); | 1027 object->set_map(Map::cast(new_map)); |
1054 } | 1028 } |
1055 return needs_access_checks ? isolate->heap()->true_value() | 1029 return needs_access_checks ? isolate->heap()->true_value() |
1056 : isolate->heap()->false_value(); | 1030 : isolate->heap()->false_value(); |
1057 } | 1031 } |
1058 | 1032 |
1059 | 1033 |
1060 static MaybeObject* Runtime_EnableAccessChecks(RUNTIME_CALLING_CONVENTION) { | 1034 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { |
1061 RUNTIME_GET_ISOLATE; | |
1062 ASSERT(args.length() == 1); | 1035 ASSERT(args.length() == 1); |
1063 CONVERT_CHECKED(HeapObject, object, args[0]); | 1036 CONVERT_CHECKED(HeapObject, object, args[0]); |
1064 Map* old_map = object->map(); | 1037 Map* old_map = object->map(); |
1065 if (!old_map->is_access_check_needed()) { | 1038 if (!old_map->is_access_check_needed()) { |
1066 // Copy map so it won't interfere constructor's initial map. | 1039 // Copy map so it won't interfere constructor's initial map. |
1067 Object* new_map; | 1040 Object* new_map; |
1068 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); | 1041 { MaybeObject* maybe_new_map = old_map->CopyDropTransitions(); |
1069 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 1042 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
1070 } | 1043 } |
1071 | 1044 |
(...skipping 10 matching lines...) Expand all Loading... |
1082 HandleScope scope(isolate); | 1055 HandleScope scope(isolate); |
1083 Handle<Object> type_handle = | 1056 Handle<Object> type_handle = |
1084 isolate->factory()->NewStringFromAscii(CStrVector(type)); | 1057 isolate->factory()->NewStringFromAscii(CStrVector(type)); |
1085 Handle<Object> args[2] = { type_handle, name }; | 1058 Handle<Object> args[2] = { type_handle, name }; |
1086 Handle<Object> error = | 1059 Handle<Object> error = |
1087 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); | 1060 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); |
1088 return isolate->Throw(*error); | 1061 return isolate->Throw(*error); |
1089 } | 1062 } |
1090 | 1063 |
1091 | 1064 |
1092 static MaybeObject* Runtime_DeclareGlobals(RUNTIME_CALLING_CONVENTION) { | 1065 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareGlobals) { |
1093 RUNTIME_GET_ISOLATE; | |
1094 ASSERT(args.length() == 4); | 1066 ASSERT(args.length() == 4); |
1095 HandleScope scope(isolate); | 1067 HandleScope scope(isolate); |
1096 Handle<GlobalObject> global = Handle<GlobalObject>( | 1068 Handle<GlobalObject> global = Handle<GlobalObject>( |
1097 isolate->context()->global()); | 1069 isolate->context()->global()); |
1098 | 1070 |
1099 Handle<Context> context = args.at<Context>(0); | 1071 Handle<Context> context = args.at<Context>(0); |
1100 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); | 1072 CONVERT_ARG_CHECKED(FixedArray, pairs, 1); |
1101 bool is_eval = Smi::cast(args[2])->value() == 1; | 1073 bool is_eval = Smi::cast(args[2])->value() == 1; |
1102 StrictModeFlag strict_mode = | 1074 StrictModeFlag strict_mode = |
1103 static_cast<StrictModeFlag>(Smi::cast(args[3])->value()); | 1075 static_cast<StrictModeFlag>(Smi::cast(args[3])->value()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 attributes, | 1198 attributes, |
1227 strict_mode)); | 1199 strict_mode)); |
1228 } | 1200 } |
1229 } | 1201 } |
1230 | 1202 |
1231 ASSERT(!isolate->has_pending_exception()); | 1203 ASSERT(!isolate->has_pending_exception()); |
1232 return isolate->heap()->undefined_value(); | 1204 return isolate->heap()->undefined_value(); |
1233 } | 1205 } |
1234 | 1206 |
1235 | 1207 |
1236 static MaybeObject* Runtime_DeclareContextSlot(RUNTIME_CALLING_CONVENTION) { | 1208 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { |
1237 RUNTIME_GET_ISOLATE; | |
1238 HandleScope scope(isolate); | 1209 HandleScope scope(isolate); |
1239 ASSERT(args.length() == 4); | 1210 ASSERT(args.length() == 4); |
1240 | 1211 |
1241 CONVERT_ARG_CHECKED(Context, context, 0); | 1212 CONVERT_ARG_CHECKED(Context, context, 0); |
1242 Handle<String> name(String::cast(args[1])); | 1213 Handle<String> name(String::cast(args[1])); |
1243 PropertyAttributes mode = | 1214 PropertyAttributes mode = |
1244 static_cast<PropertyAttributes>(Smi::cast(args[2])->value()); | 1215 static_cast<PropertyAttributes>(Smi::cast(args[2])->value()); |
1245 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); | 1216 RUNTIME_ASSERT(mode == READ_ONLY || mode == NONE); |
1246 Handle<Object> initial_value(args[3], isolate); | 1217 Handle<Object> initial_value(args[3], isolate); |
1247 | 1218 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 } | 1304 } |
1334 RETURN_IF_EMPTY_HANDLE(isolate, | 1305 RETURN_IF_EMPTY_HANDLE(isolate, |
1335 SetProperty(context_ext, name, value, mode, | 1306 SetProperty(context_ext, name, value, mode, |
1336 kNonStrictMode)); | 1307 kNonStrictMode)); |
1337 } | 1308 } |
1338 | 1309 |
1339 return isolate->heap()->undefined_value(); | 1310 return isolate->heap()->undefined_value(); |
1340 } | 1311 } |
1341 | 1312 |
1342 | 1313 |
1343 static MaybeObject* Runtime_InitializeVarGlobal(RUNTIME_CALLING_CONVENTION) { | 1314 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { |
1344 RUNTIME_GET_ISOLATE; | |
1345 NoHandleAllocation nha; | 1315 NoHandleAllocation nha; |
1346 // args[0] == name | 1316 // args[0] == name |
1347 // args[1] == strict_mode | 1317 // args[1] == strict_mode |
1348 // args[2] == value (optional) | 1318 // args[2] == value (optional) |
1349 | 1319 |
1350 // Determine if we need to assign to the variable if it already | 1320 // Determine if we need to assign to the variable if it already |
1351 // exists (based on the number of arguments). | 1321 // exists (based on the number of arguments). |
1352 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 1322 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
1353 bool assign = args.length() == 3; | 1323 bool assign = args.length() == 3; |
1354 | 1324 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 } | 1399 } |
1430 | 1400 |
1431 global = isolate->context()->global(); | 1401 global = isolate->context()->global(); |
1432 if (assign) { | 1402 if (assign) { |
1433 return global->SetProperty(*name, args[2], attributes, strict_mode); | 1403 return global->SetProperty(*name, args[2], attributes, strict_mode); |
1434 } | 1404 } |
1435 return isolate->heap()->undefined_value(); | 1405 return isolate->heap()->undefined_value(); |
1436 } | 1406 } |
1437 | 1407 |
1438 | 1408 |
1439 static MaybeObject* Runtime_InitializeConstGlobal(RUNTIME_CALLING_CONVENTION) { | 1409 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstGlobal) { |
1440 RUNTIME_GET_ISOLATE; | |
1441 // All constants are declared with an initial value. The name | 1410 // All constants are declared with an initial value. The name |
1442 // of the constant is the first argument and the initial value | 1411 // of the constant is the first argument and the initial value |
1443 // is the second. | 1412 // is the second. |
1444 RUNTIME_ASSERT(args.length() == 2); | 1413 RUNTIME_ASSERT(args.length() == 2); |
1445 CONVERT_ARG_CHECKED(String, name, 0); | 1414 CONVERT_ARG_CHECKED(String, name, 0); |
1446 Handle<Object> value = args.at<Object>(1); | 1415 Handle<Object> value = args.at<Object>(1); |
1447 | 1416 |
1448 // Get the current global object from top. | 1417 // Get the current global object from top. |
1449 GlobalObject* global = isolate->context()->global(); | 1418 GlobalObject* global = isolate->context()->global(); |
1450 | 1419 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 // Ignore re-initialization of constants that have already been | 1489 // Ignore re-initialization of constants that have already been |
1521 // assigned a function value. | 1490 // assigned a function value. |
1522 ASSERT(lookup.IsReadOnly() && type == CONSTANT_FUNCTION); | 1491 ASSERT(lookup.IsReadOnly() && type == CONSTANT_FUNCTION); |
1523 } | 1492 } |
1524 | 1493 |
1525 // Use the set value as the result of the operation. | 1494 // Use the set value as the result of the operation. |
1526 return *value; | 1495 return *value; |
1527 } | 1496 } |
1528 | 1497 |
1529 | 1498 |
1530 static MaybeObject* Runtime_InitializeConstContextSlot( | 1499 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) { |
1531 RUNTIME_CALLING_CONVENTION) { | |
1532 RUNTIME_GET_ISOLATE; | |
1533 HandleScope scope(isolate); | 1500 HandleScope scope(isolate); |
1534 ASSERT(args.length() == 3); | 1501 ASSERT(args.length() == 3); |
1535 | 1502 |
1536 Handle<Object> value(args[0], isolate); | 1503 Handle<Object> value(args[0], isolate); |
1537 ASSERT(!value->IsTheHole()); | 1504 ASSERT(!value->IsTheHole()); |
1538 CONVERT_ARG_CHECKED(Context, context, 1); | 1505 CONVERT_ARG_CHECKED(Context, context, 1); |
1539 Handle<String> name(String::cast(args[2])); | 1506 Handle<String> name(String::cast(args[2])); |
1540 | 1507 |
1541 // Initializations are always done in the function context. | 1508 // Initializations are always done in the function context. |
1542 context = Handle<Context>(context->fcontext()); | 1509 context = Handle<Context>(context->fcontext()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 RETURN_IF_EMPTY_HANDLE( | 1596 RETURN_IF_EMPTY_HANDLE( |
1630 isolate, | 1597 isolate, |
1631 SetProperty(context_ext, name, value, attributes, kNonStrictMode)); | 1598 SetProperty(context_ext, name, value, attributes, kNonStrictMode)); |
1632 } | 1599 } |
1633 } | 1600 } |
1634 | 1601 |
1635 return *value; | 1602 return *value; |
1636 } | 1603 } |
1637 | 1604 |
1638 | 1605 |
1639 static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties( | 1606 RUNTIME_FUNCTION(MaybeObject*, |
1640 RUNTIME_CALLING_CONVENTION) { | 1607 Runtime_OptimizeObjectForAddingMultipleProperties) { |
1641 RUNTIME_GET_ISOLATE; | |
1642 HandleScope scope(isolate); | 1608 HandleScope scope(isolate); |
1643 ASSERT(args.length() == 2); | 1609 ASSERT(args.length() == 2); |
1644 CONVERT_ARG_CHECKED(JSObject, object, 0); | 1610 CONVERT_ARG_CHECKED(JSObject, object, 0); |
1645 CONVERT_SMI_CHECKED(properties, args[1]); | 1611 CONVERT_SMI_CHECKED(properties, args[1]); |
1646 if (object->HasFastProperties()) { | 1612 if (object->HasFastProperties()) { |
1647 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 1613 NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
1648 } | 1614 } |
1649 return *object; | 1615 return *object; |
1650 } | 1616 } |
1651 | 1617 |
1652 | 1618 |
1653 static MaybeObject* Runtime_RegExpExec(RUNTIME_CALLING_CONVENTION) { | 1619 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExec) { |
1654 RUNTIME_GET_ISOLATE; | |
1655 HandleScope scope(isolate); | 1620 HandleScope scope(isolate); |
1656 ASSERT(args.length() == 4); | 1621 ASSERT(args.length() == 4); |
1657 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 1622 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
1658 CONVERT_ARG_CHECKED(String, subject, 1); | 1623 CONVERT_ARG_CHECKED(String, subject, 1); |
1659 // Due to the way the JS calls are constructed this must be less than the | 1624 // Due to the way the JS calls are constructed this must be less than the |
1660 // length of a string, i.e. it is always a Smi. We check anyway for security. | 1625 // length of a string, i.e. it is always a Smi. We check anyway for security. |
1661 CONVERT_SMI_CHECKED(index, args[2]); | 1626 CONVERT_SMI_CHECKED(index, args[2]); |
1662 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); | 1627 CONVERT_ARG_CHECKED(JSArray, last_match_info, 3); |
1663 RUNTIME_ASSERT(last_match_info->HasFastElements()); | 1628 RUNTIME_ASSERT(last_match_info->HasFastElements()); |
1664 RUNTIME_ASSERT(index >= 0); | 1629 RUNTIME_ASSERT(index >= 0); |
1665 RUNTIME_ASSERT(index <= subject->length()); | 1630 RUNTIME_ASSERT(index <= subject->length()); |
1666 isolate->counters()->regexp_entry_runtime()->Increment(); | 1631 isolate->counters()->regexp_entry_runtime()->Increment(); |
1667 Handle<Object> result = RegExpImpl::Exec(regexp, | 1632 Handle<Object> result = RegExpImpl::Exec(regexp, |
1668 subject, | 1633 subject, |
1669 index, | 1634 index, |
1670 last_match_info); | 1635 last_match_info); |
1671 if (result.is_null()) return Failure::Exception(); | 1636 if (result.is_null()) return Failure::Exception(); |
1672 return *result; | 1637 return *result; |
1673 } | 1638 } |
1674 | 1639 |
1675 | 1640 |
1676 static MaybeObject* Runtime_RegExpConstructResult(RUNTIME_CALLING_CONVENTION) { | 1641 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpConstructResult) { |
1677 RUNTIME_GET_ISOLATE; | |
1678 ASSERT(args.length() == 3); | 1642 ASSERT(args.length() == 3); |
1679 CONVERT_SMI_CHECKED(elements_count, args[0]); | 1643 CONVERT_SMI_CHECKED(elements_count, args[0]); |
1680 if (elements_count > JSArray::kMaxFastElementsLength) { | 1644 if (elements_count > JSArray::kMaxFastElementsLength) { |
1681 return isolate->ThrowIllegalOperation(); | 1645 return isolate->ThrowIllegalOperation(); |
1682 } | 1646 } |
1683 Object* new_object; | 1647 Object* new_object; |
1684 { MaybeObject* maybe_new_object = | 1648 { MaybeObject* maybe_new_object = |
1685 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); | 1649 isolate->heap()->AllocateFixedArrayWithHoles(elements_count); |
1686 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 1650 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
1687 } | 1651 } |
(...skipping 12 matching lines...) Expand all Loading... |
1700 array->set_properties(isolate->heap()->empty_fixed_array()); | 1664 array->set_properties(isolate->heap()->empty_fixed_array()); |
1701 array->set_elements(elements); | 1665 array->set_elements(elements); |
1702 array->set_length(Smi::FromInt(elements_count)); | 1666 array->set_length(Smi::FromInt(elements_count)); |
1703 // Write in-object properties after the length of the array. | 1667 // Write in-object properties after the length of the array. |
1704 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); | 1668 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); |
1705 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); | 1669 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); |
1706 return array; | 1670 return array; |
1707 } | 1671 } |
1708 | 1672 |
1709 | 1673 |
1710 static MaybeObject* Runtime_RegExpInitializeObject(RUNTIME_CALLING_CONVENTION) { | 1674 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { |
1711 RUNTIME_GET_ISOLATE; | |
1712 AssertNoAllocation no_alloc; | 1675 AssertNoAllocation no_alloc; |
1713 ASSERT(args.length() == 5); | 1676 ASSERT(args.length() == 5); |
1714 CONVERT_CHECKED(JSRegExp, regexp, args[0]); | 1677 CONVERT_CHECKED(JSRegExp, regexp, args[0]); |
1715 CONVERT_CHECKED(String, source, args[1]); | 1678 CONVERT_CHECKED(String, source, args[1]); |
1716 | 1679 |
1717 Object* global = args[2]; | 1680 Object* global = args[2]; |
1718 if (!global->IsTrue()) global = isolate->heap()->false_value(); | 1681 if (!global->IsTrue()) global = isolate->heap()->false_value(); |
1719 | 1682 |
1720 Object* ignoreCase = args[3]; | 1683 Object* ignoreCase = args[3]; |
1721 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); | 1684 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 result = | 1730 result = |
1768 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(), | 1731 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(), |
1769 Smi::FromInt(0), | 1732 Smi::FromInt(0), |
1770 writable); | 1733 writable); |
1771 ASSERT(!result->IsFailure()); | 1734 ASSERT(!result->IsFailure()); |
1772 USE(result); | 1735 USE(result); |
1773 return regexp; | 1736 return regexp; |
1774 } | 1737 } |
1775 | 1738 |
1776 | 1739 |
1777 static MaybeObject* Runtime_FinishArrayPrototypeSetup( | 1740 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) { |
1778 RUNTIME_CALLING_CONVENTION) { | |
1779 RUNTIME_GET_ISOLATE; | |
1780 HandleScope scope(isolate); | 1741 HandleScope scope(isolate); |
1781 ASSERT(args.length() == 1); | 1742 ASSERT(args.length() == 1); |
1782 CONVERT_ARG_CHECKED(JSArray, prototype, 0); | 1743 CONVERT_ARG_CHECKED(JSArray, prototype, 0); |
1783 // This is necessary to enable fast checks for absence of elements | 1744 // This is necessary to enable fast checks for absence of elements |
1784 // on Array.prototype and below. | 1745 // on Array.prototype and below. |
1785 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 1746 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
1786 return Smi::FromInt(0); | 1747 return Smi::FromInt(0); |
1787 } | 1748 } |
1788 | 1749 |
1789 | 1750 |
1790 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, | 1751 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, |
1791 Handle<JSObject> holder, | 1752 Handle<JSObject> holder, |
1792 const char* name, | 1753 const char* name, |
1793 Builtins::Name builtin_name) { | 1754 Builtins::Name builtin_name) { |
1794 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); | 1755 Handle<String> key = isolate->factory()->LookupAsciiSymbol(name); |
1795 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 1756 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
1796 Handle<JSFunction> optimized = | 1757 Handle<JSFunction> optimized = |
1797 isolate->factory()->NewFunction(key, | 1758 isolate->factory()->NewFunction(key, |
1798 JS_OBJECT_TYPE, | 1759 JS_OBJECT_TYPE, |
1799 JSObject::kHeaderSize, | 1760 JSObject::kHeaderSize, |
1800 code, | 1761 code, |
1801 false); | 1762 false); |
1802 optimized->shared()->DontAdaptArguments(); | 1763 optimized->shared()->DontAdaptArguments(); |
1803 SetProperty(holder, key, optimized, NONE, kStrictMode); | 1764 SetProperty(holder, key, optimized, NONE, kStrictMode); |
1804 return optimized; | 1765 return optimized; |
1805 } | 1766 } |
1806 | 1767 |
1807 | 1768 |
1808 static MaybeObject* Runtime_SpecialArrayFunctions(RUNTIME_CALLING_CONVENTION) { | 1769 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { |
1809 RUNTIME_GET_ISOLATE; | |
1810 HandleScope scope(isolate); | 1770 HandleScope scope(isolate); |
1811 ASSERT(args.length() == 1); | 1771 ASSERT(args.length() == 1); |
1812 CONVERT_ARG_CHECKED(JSObject, holder, 0); | 1772 CONVERT_ARG_CHECKED(JSObject, holder, 0); |
1813 | 1773 |
1814 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 1774 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
1815 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); | 1775 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); |
1816 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 1776 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
1817 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 1777 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
1818 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 1778 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
1819 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 1779 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
1820 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 1780 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
1821 | 1781 |
1822 return *holder; | 1782 return *holder; |
1823 } | 1783 } |
1824 | 1784 |
1825 | 1785 |
1826 static MaybeObject* Runtime_GetGlobalReceiver(RUNTIME_CALLING_CONVENTION) { | 1786 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetGlobalReceiver) { |
1827 RUNTIME_GET_ISOLATE; | |
1828 // Returns a real global receiver, not one of builtins object. | 1787 // Returns a real global receiver, not one of builtins object. |
1829 Context* global_context = | 1788 Context* global_context = |
1830 isolate->context()->global()->global_context(); | 1789 isolate->context()->global()->global_context(); |
1831 return global_context->global()->global_receiver(); | 1790 return global_context->global()->global_receiver(); |
1832 } | 1791 } |
1833 | 1792 |
1834 | 1793 |
1835 static MaybeObject* Runtime_MaterializeRegExpLiteral( | 1794 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaterializeRegExpLiteral) { |
1836 RUNTIME_CALLING_CONVENTION) { | |
1837 RUNTIME_GET_ISOLATE; | |
1838 HandleScope scope(isolate); | 1795 HandleScope scope(isolate); |
1839 ASSERT(args.length() == 4); | 1796 ASSERT(args.length() == 4); |
1840 CONVERT_ARG_CHECKED(FixedArray, literals, 0); | 1797 CONVERT_ARG_CHECKED(FixedArray, literals, 0); |
1841 int index = Smi::cast(args[1])->value(); | 1798 int index = Smi::cast(args[1])->value(); |
1842 Handle<String> pattern = args.at<String>(2); | 1799 Handle<String> pattern = args.at<String>(2); |
1843 Handle<String> flags = args.at<String>(3); | 1800 Handle<String> flags = args.at<String>(3); |
1844 | 1801 |
1845 // Get the RegExp function from the context in the literals array. | 1802 // Get the RegExp function from the context in the literals array. |
1846 // This is the RegExp function from the context in which the | 1803 // This is the RegExp function from the context in which the |
1847 // function was created. We do not use the RegExp function from the | 1804 // function was created. We do not use the RegExp function from the |
1848 // current global context because this might be the RegExp function | 1805 // current global context because this might be the RegExp function |
1849 // from another context which we should not have access to. | 1806 // from another context which we should not have access to. |
1850 Handle<JSFunction> constructor = | 1807 Handle<JSFunction> constructor = |
1851 Handle<JSFunction>( | 1808 Handle<JSFunction>( |
1852 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function()); | 1809 JSFunction::GlobalContextFromLiterals(*literals)->regexp_function()); |
1853 // Compute the regular expression literal. | 1810 // Compute the regular expression literal. |
1854 bool has_pending_exception; | 1811 bool has_pending_exception; |
1855 Handle<Object> regexp = | 1812 Handle<Object> regexp = |
1856 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags, | 1813 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags, |
1857 &has_pending_exception); | 1814 &has_pending_exception); |
1858 if (has_pending_exception) { | 1815 if (has_pending_exception) { |
1859 ASSERT(isolate->has_pending_exception()); | 1816 ASSERT(isolate->has_pending_exception()); |
1860 return Failure::Exception(); | 1817 return Failure::Exception(); |
1861 } | 1818 } |
1862 literals->set(index, *regexp); | 1819 literals->set(index, *regexp); |
1863 return *regexp; | 1820 return *regexp; |
1864 } | 1821 } |
1865 | 1822 |
1866 | 1823 |
1867 static MaybeObject* Runtime_FunctionGetName(RUNTIME_CALLING_CONVENTION) { | 1824 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { |
1868 RUNTIME_GET_ISOLATE; | |
1869 NoHandleAllocation ha; | 1825 NoHandleAllocation ha; |
1870 ASSERT(args.length() == 1); | 1826 ASSERT(args.length() == 1); |
1871 | 1827 |
1872 CONVERT_CHECKED(JSFunction, f, args[0]); | 1828 CONVERT_CHECKED(JSFunction, f, args[0]); |
1873 return f->shared()->name(); | 1829 return f->shared()->name(); |
1874 } | 1830 } |
1875 | 1831 |
1876 | 1832 |
1877 static MaybeObject* Runtime_FunctionSetName(RUNTIME_CALLING_CONVENTION) { | 1833 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { |
1878 RUNTIME_GET_ISOLATE; | |
1879 NoHandleAllocation ha; | 1834 NoHandleAllocation ha; |
1880 ASSERT(args.length() == 2); | 1835 ASSERT(args.length() == 2); |
1881 | 1836 |
1882 CONVERT_CHECKED(JSFunction, f, args[0]); | 1837 CONVERT_CHECKED(JSFunction, f, args[0]); |
1883 CONVERT_CHECKED(String, name, args[1]); | 1838 CONVERT_CHECKED(String, name, args[1]); |
1884 f->shared()->set_name(name); | 1839 f->shared()->set_name(name); |
1885 return isolate->heap()->undefined_value(); | 1840 return isolate->heap()->undefined_value(); |
1886 } | 1841 } |
1887 | 1842 |
1888 | 1843 |
1889 static MaybeObject* Runtime_FunctionRemovePrototype( | 1844 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
1890 RUNTIME_CALLING_CONVENTION) { | |
1891 RUNTIME_GET_ISOLATE; | |
1892 NoHandleAllocation ha; | 1845 NoHandleAllocation ha; |
1893 ASSERT(args.length() == 1); | 1846 ASSERT(args.length() == 1); |
1894 | 1847 |
1895 CONVERT_CHECKED(JSFunction, f, args[0]); | 1848 CONVERT_CHECKED(JSFunction, f, args[0]); |
1896 Object* obj = f->RemovePrototype(); | 1849 Object* obj = f->RemovePrototype(); |
1897 if (obj->IsFailure()) return obj; | 1850 if (obj->IsFailure()) return obj; |
1898 | 1851 |
1899 return isolate->heap()->undefined_value(); | 1852 return isolate->heap()->undefined_value(); |
1900 } | 1853 } |
1901 | 1854 |
1902 | 1855 |
1903 static MaybeObject* Runtime_FunctionGetScript(RUNTIME_CALLING_CONVENTION) { | 1856 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { |
1904 RUNTIME_GET_ISOLATE; | |
1905 HandleScope scope(isolate); | 1857 HandleScope scope(isolate); |
1906 ASSERT(args.length() == 1); | 1858 ASSERT(args.length() == 1); |
1907 | 1859 |
1908 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1860 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1909 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); | 1861 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); |
1910 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 1862 if (!script->IsScript()) return isolate->heap()->undefined_value(); |
1911 | 1863 |
1912 return *GetScriptWrapper(Handle<Script>::cast(script)); | 1864 return *GetScriptWrapper(Handle<Script>::cast(script)); |
1913 } | 1865 } |
1914 | 1866 |
1915 | 1867 |
1916 static MaybeObject* Runtime_FunctionGetSourceCode(RUNTIME_CALLING_CONVENTION) { | 1868 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { |
1917 RUNTIME_GET_ISOLATE; | |
1918 NoHandleAllocation ha; | 1869 NoHandleAllocation ha; |
1919 ASSERT(args.length() == 1); | 1870 ASSERT(args.length() == 1); |
1920 | 1871 |
1921 CONVERT_CHECKED(JSFunction, f, args[0]); | 1872 CONVERT_CHECKED(JSFunction, f, args[0]); |
1922 return f->shared()->GetSourceCode(); | 1873 return f->shared()->GetSourceCode(); |
1923 } | 1874 } |
1924 | 1875 |
1925 | 1876 |
1926 static MaybeObject* Runtime_FunctionGetScriptSourcePosition( | 1877 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { |
1927 RUNTIME_CALLING_CONVENTION) { | |
1928 RUNTIME_GET_ISOLATE; | |
1929 NoHandleAllocation ha; | 1878 NoHandleAllocation ha; |
1930 ASSERT(args.length() == 1); | 1879 ASSERT(args.length() == 1); |
1931 | 1880 |
1932 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1881 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1933 int pos = fun->shared()->start_position(); | 1882 int pos = fun->shared()->start_position(); |
1934 return Smi::FromInt(pos); | 1883 return Smi::FromInt(pos); |
1935 } | 1884 } |
1936 | 1885 |
1937 | 1886 |
1938 static MaybeObject* Runtime_FunctionGetPositionForOffset( | 1887 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { |
1939 RUNTIME_CALLING_CONVENTION) { | |
1940 RUNTIME_GET_ISOLATE; | |
1941 ASSERT(args.length() == 2); | 1888 ASSERT(args.length() == 2); |
1942 | 1889 |
1943 CONVERT_CHECKED(Code, code, args[0]); | 1890 CONVERT_CHECKED(Code, code, args[0]); |
1944 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 1891 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
1945 | 1892 |
1946 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 1893 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
1947 | 1894 |
1948 Address pc = code->address() + offset; | 1895 Address pc = code->address() + offset; |
1949 return Smi::FromInt(code->SourcePosition(pc)); | 1896 return Smi::FromInt(code->SourcePosition(pc)); |
1950 } | 1897 } |
1951 | 1898 |
1952 | 1899 |
1953 static MaybeObject* Runtime_FunctionSetInstanceClassName( | 1900 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { |
1954 RUNTIME_CALLING_CONVENTION) { | |
1955 RUNTIME_GET_ISOLATE; | |
1956 NoHandleAllocation ha; | 1901 NoHandleAllocation ha; |
1957 ASSERT(args.length() == 2); | 1902 ASSERT(args.length() == 2); |
1958 | 1903 |
1959 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1904 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1960 CONVERT_CHECKED(String, name, args[1]); | 1905 CONVERT_CHECKED(String, name, args[1]); |
1961 fun->SetInstanceClassName(name); | 1906 fun->SetInstanceClassName(name); |
1962 return isolate->heap()->undefined_value(); | 1907 return isolate->heap()->undefined_value(); |
1963 } | 1908 } |
1964 | 1909 |
1965 | 1910 |
1966 static MaybeObject* Runtime_FunctionSetLength(RUNTIME_CALLING_CONVENTION) { | 1911 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { |
1967 RUNTIME_GET_ISOLATE; | |
1968 NoHandleAllocation ha; | 1912 NoHandleAllocation ha; |
1969 ASSERT(args.length() == 2); | 1913 ASSERT(args.length() == 2); |
1970 | 1914 |
1971 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1915 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1972 CONVERT_CHECKED(Smi, length, args[1]); | 1916 CONVERT_CHECKED(Smi, length, args[1]); |
1973 fun->shared()->set_length(length->value()); | 1917 fun->shared()->set_length(length->value()); |
1974 return length; | 1918 return length; |
1975 } | 1919 } |
1976 | 1920 |
1977 | 1921 |
1978 static MaybeObject* Runtime_FunctionSetPrototype(RUNTIME_CALLING_CONVENTION) { | 1922 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { |
1979 RUNTIME_GET_ISOLATE; | |
1980 NoHandleAllocation ha; | 1923 NoHandleAllocation ha; |
1981 ASSERT(args.length() == 2); | 1924 ASSERT(args.length() == 2); |
1982 | 1925 |
1983 CONVERT_CHECKED(JSFunction, fun, args[0]); | 1926 CONVERT_CHECKED(JSFunction, fun, args[0]); |
1984 ASSERT(fun->should_have_prototype()); | 1927 ASSERT(fun->should_have_prototype()); |
1985 Object* obj; | 1928 Object* obj; |
1986 { MaybeObject* maybe_obj = | 1929 { MaybeObject* maybe_obj = |
1987 Accessors::FunctionSetPrototype(fun, args[1], NULL); | 1930 Accessors::FunctionSetPrototype(fun, args[1], NULL); |
1988 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 1931 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
1989 } | 1932 } |
1990 return args[0]; // return TOS | 1933 return args[0]; // return TOS |
1991 } | 1934 } |
1992 | 1935 |
1993 | 1936 |
1994 static MaybeObject* Runtime_FunctionIsAPIFunction(RUNTIME_CALLING_CONVENTION) { | 1937 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { |
1995 RUNTIME_GET_ISOLATE; | |
1996 NoHandleAllocation ha; | 1938 NoHandleAllocation ha; |
1997 ASSERT(args.length() == 1); | 1939 ASSERT(args.length() == 1); |
1998 | 1940 |
1999 CONVERT_CHECKED(JSFunction, f, args[0]); | 1941 CONVERT_CHECKED(JSFunction, f, args[0]); |
2000 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() | 1942 return f->shared()->IsApiFunction() ? isolate->heap()->true_value() |
2001 : isolate->heap()->false_value(); | 1943 : isolate->heap()->false_value(); |
2002 } | 1944 } |
2003 | 1945 |
2004 | 1946 |
2005 static MaybeObject* Runtime_FunctionIsBuiltin(RUNTIME_CALLING_CONVENTION) { | 1947 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { |
2006 RUNTIME_GET_ISOLATE; | |
2007 NoHandleAllocation ha; | 1948 NoHandleAllocation ha; |
2008 ASSERT(args.length() == 1); | 1949 ASSERT(args.length() == 1); |
2009 | 1950 |
2010 CONVERT_CHECKED(JSFunction, f, args[0]); | 1951 CONVERT_CHECKED(JSFunction, f, args[0]); |
2011 return f->IsBuiltin() ? isolate->heap()->true_value() : | 1952 return f->IsBuiltin() ? isolate->heap()->true_value() : |
2012 isolate->heap()->false_value(); | 1953 isolate->heap()->false_value(); |
2013 } | 1954 } |
2014 | 1955 |
2015 | 1956 |
2016 static MaybeObject* Runtime_SetCode(RUNTIME_CALLING_CONVENTION) { | 1957 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
2017 RUNTIME_GET_ISOLATE; | |
2018 HandleScope scope(isolate); | 1958 HandleScope scope(isolate); |
2019 ASSERT(args.length() == 2); | 1959 ASSERT(args.length() == 2); |
2020 | 1960 |
2021 CONVERT_ARG_CHECKED(JSFunction, target, 0); | 1961 CONVERT_ARG_CHECKED(JSFunction, target, 0); |
2022 Handle<Object> code = args.at<Object>(1); | 1962 Handle<Object> code = args.at<Object>(1); |
2023 | 1963 |
2024 Handle<Context> context(target->context()); | 1964 Handle<Context> context(target->context()); |
2025 | 1965 |
2026 if (!code->IsNull()) { | 1966 if (!code->IsNull()) { |
2027 RUNTIME_ASSERT(code->IsJSFunction()); | 1967 RUNTIME_ASSERT(code->IsJSFunction()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 // are guaranteed to be in old space. | 2010 // are guaranteed to be in old space. |
2071 target->set_literals(*literals, SKIP_WRITE_BARRIER); | 2011 target->set_literals(*literals, SKIP_WRITE_BARRIER); |
2072 target->set_next_function_link(isolate->heap()->undefined_value()); | 2012 target->set_next_function_link(isolate->heap()->undefined_value()); |
2073 } | 2013 } |
2074 | 2014 |
2075 target->set_context(*context); | 2015 target->set_context(*context); |
2076 return *target; | 2016 return *target; |
2077 } | 2017 } |
2078 | 2018 |
2079 | 2019 |
2080 static MaybeObject* Runtime_SetExpectedNumberOfProperties( | 2020 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { |
2081 RUNTIME_CALLING_CONVENTION) { | |
2082 RUNTIME_GET_ISOLATE; | |
2083 HandleScope scope(isolate); | 2021 HandleScope scope(isolate); |
2084 ASSERT(args.length() == 2); | 2022 ASSERT(args.length() == 2); |
2085 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 2023 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
2086 CONVERT_SMI_CHECKED(num, args[1]); | 2024 CONVERT_SMI_CHECKED(num, args[1]); |
2087 RUNTIME_ASSERT(num >= 0); | 2025 RUNTIME_ASSERT(num >= 0); |
2088 SetExpectedNofProperties(function, num); | 2026 SetExpectedNofProperties(function, num); |
2089 return isolate->heap()->undefined_value(); | 2027 return isolate->heap()->undefined_value(); |
2090 } | 2028 } |
2091 | 2029 |
2092 | 2030 |
2093 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, | 2031 MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, |
2094 Object* char_code) { | 2032 Object* char_code) { |
2095 uint32_t code; | 2033 uint32_t code; |
2096 if (char_code->ToArrayIndex(&code)) { | 2034 if (char_code->ToArrayIndex(&code)) { |
2097 if (code <= 0xffff) { | 2035 if (code <= 0xffff) { |
2098 return isolate->heap()->LookupSingleCharacterStringFromCode(code); | 2036 return isolate->heap()->LookupSingleCharacterStringFromCode(code); |
2099 } | 2037 } |
2100 } | 2038 } |
2101 return isolate->heap()->empty_string(); | 2039 return isolate->heap()->empty_string(); |
2102 } | 2040 } |
2103 | 2041 |
2104 | 2042 |
2105 static MaybeObject* Runtime_StringCharCodeAt(RUNTIME_CALLING_CONVENTION) { | 2043 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
2106 RUNTIME_GET_ISOLATE; | |
2107 NoHandleAllocation ha; | 2044 NoHandleAllocation ha; |
2108 ASSERT(args.length() == 2); | 2045 ASSERT(args.length() == 2); |
2109 | 2046 |
2110 CONVERT_CHECKED(String, subject, args[0]); | 2047 CONVERT_CHECKED(String, subject, args[0]); |
2111 Object* index = args[1]; | 2048 Object* index = args[1]; |
2112 RUNTIME_ASSERT(index->IsNumber()); | 2049 RUNTIME_ASSERT(index->IsNumber()); |
2113 | 2050 |
2114 uint32_t i = 0; | 2051 uint32_t i = 0; |
2115 if (index->IsSmi()) { | 2052 if (index->IsSmi()) { |
2116 int value = Smi::cast(index)->value(); | 2053 int value = Smi::cast(index)->value(); |
(...skipping 15 matching lines...) Expand all Loading... |
2132 subject = String::cast(flat); | 2069 subject = String::cast(flat); |
2133 | 2070 |
2134 if (i >= static_cast<uint32_t>(subject->length())) { | 2071 if (i >= static_cast<uint32_t>(subject->length())) { |
2135 return isolate->heap()->nan_value(); | 2072 return isolate->heap()->nan_value(); |
2136 } | 2073 } |
2137 | 2074 |
2138 return Smi::FromInt(subject->Get(i)); | 2075 return Smi::FromInt(subject->Get(i)); |
2139 } | 2076 } |
2140 | 2077 |
2141 | 2078 |
2142 static MaybeObject* Runtime_CharFromCode(RUNTIME_CALLING_CONVENTION) { | 2079 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { |
2143 RUNTIME_GET_ISOLATE; | |
2144 NoHandleAllocation ha; | 2080 NoHandleAllocation ha; |
2145 ASSERT(args.length() == 1); | 2081 ASSERT(args.length() == 1); |
2146 return CharFromCode(isolate, args[0]); | 2082 return CharFromCode(isolate, args[0]); |
2147 } | 2083 } |
2148 | 2084 |
2149 | 2085 |
2150 class FixedArrayBuilder { | 2086 class FixedArrayBuilder { |
2151 public: | 2087 public: |
2152 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) | 2088 explicit FixedArrayBuilder(Isolate* isolate, int initial_capacity) |
2153 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), | 2089 : array_(isolate->factory()->NewFixedArrayWithHoles(initial_capacity)), |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2867 answer->set_length(position); | 2803 answer->set_length(position); |
2868 if (delta == 0) return *answer; | 2804 if (delta == 0) return *answer; |
2869 | 2805 |
2870 Address end_of_string = answer->address() + string_size; | 2806 Address end_of_string = answer->address() + string_size; |
2871 isolate->heap()->CreateFillerObjectAt(end_of_string, delta); | 2807 isolate->heap()->CreateFillerObjectAt(end_of_string, delta); |
2872 | 2808 |
2873 return *answer; | 2809 return *answer; |
2874 } | 2810 } |
2875 | 2811 |
2876 | 2812 |
2877 static MaybeObject* Runtime_StringReplaceRegExpWithString( | 2813 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) { |
2878 RUNTIME_CALLING_CONVENTION) { | |
2879 RUNTIME_GET_ISOLATE; | |
2880 ASSERT(args.length() == 4); | 2814 ASSERT(args.length() == 4); |
2881 | 2815 |
2882 CONVERT_CHECKED(String, subject, args[0]); | 2816 CONVERT_CHECKED(String, subject, args[0]); |
2883 if (!subject->IsFlat()) { | 2817 if (!subject->IsFlat()) { |
2884 Object* flat_subject; | 2818 Object* flat_subject; |
2885 { MaybeObject* maybe_flat_subject = subject->TryFlatten(); | 2819 { MaybeObject* maybe_flat_subject = subject->TryFlatten(); |
2886 if (!maybe_flat_subject->ToObject(&flat_subject)) { | 2820 if (!maybe_flat_subject->ToObject(&flat_subject)) { |
2887 return maybe_flat_subject; | 2821 return maybe_flat_subject; |
2888 } | 2822 } |
2889 } | 2823 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 pat_vector, | 2905 pat_vector, |
2972 start_index); | 2906 start_index); |
2973 } | 2907 } |
2974 return SearchString(isolate, | 2908 return SearchString(isolate, |
2975 seq_sub->ToUC16Vector(), | 2909 seq_sub->ToUC16Vector(), |
2976 pat_vector, | 2910 pat_vector, |
2977 start_index); | 2911 start_index); |
2978 } | 2912 } |
2979 | 2913 |
2980 | 2914 |
2981 static MaybeObject* Runtime_StringIndexOf(RUNTIME_CALLING_CONVENTION) { | 2915 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { |
2982 RUNTIME_GET_ISOLATE; | |
2983 HandleScope scope(isolate); // create a new handle scope | 2916 HandleScope scope(isolate); // create a new handle scope |
2984 ASSERT(args.length() == 3); | 2917 ASSERT(args.length() == 3); |
2985 | 2918 |
2986 CONVERT_ARG_CHECKED(String, sub, 0); | 2919 CONVERT_ARG_CHECKED(String, sub, 0); |
2987 CONVERT_ARG_CHECKED(String, pat, 1); | 2920 CONVERT_ARG_CHECKED(String, pat, 1); |
2988 | 2921 |
2989 Object* index = args[2]; | 2922 Object* index = args[2]; |
2990 uint32_t start_index; | 2923 uint32_t start_index; |
2991 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 2924 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
2992 | 2925 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 } | 2957 } |
3025 j++; | 2958 j++; |
3026 } | 2959 } |
3027 if (j == pattern_length) { | 2960 if (j == pattern_length) { |
3028 return i; | 2961 return i; |
3029 } | 2962 } |
3030 } | 2963 } |
3031 return -1; | 2964 return -1; |
3032 } | 2965 } |
3033 | 2966 |
3034 static MaybeObject* Runtime_StringLastIndexOf(RUNTIME_CALLING_CONVENTION) { | 2967 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { |
3035 RUNTIME_GET_ISOLATE; | |
3036 HandleScope scope(isolate); // create a new handle scope | 2968 HandleScope scope(isolate); // create a new handle scope |
3037 ASSERT(args.length() == 3); | 2969 ASSERT(args.length() == 3); |
3038 | 2970 |
3039 CONVERT_ARG_CHECKED(String, sub, 0); | 2971 CONVERT_ARG_CHECKED(String, sub, 0); |
3040 CONVERT_ARG_CHECKED(String, pat, 1); | 2972 CONVERT_ARG_CHECKED(String, pat, 1); |
3041 | 2973 |
3042 Object* index = args[2]; | 2974 Object* index = args[2]; |
3043 uint32_t start_index; | 2975 uint32_t start_index; |
3044 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 2976 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
3045 | 2977 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3082 position = StringMatchBackwards(sub->ToUC16Vector(), | 3014 position = StringMatchBackwards(sub->ToUC16Vector(), |
3083 pat_vector, | 3015 pat_vector, |
3084 start_index); | 3016 start_index); |
3085 } | 3017 } |
3086 } | 3018 } |
3087 | 3019 |
3088 return Smi::FromInt(position); | 3020 return Smi::FromInt(position); |
3089 } | 3021 } |
3090 | 3022 |
3091 | 3023 |
3092 static MaybeObject* Runtime_StringLocaleCompare(RUNTIME_CALLING_CONVENTION) { | 3024 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { |
3093 RUNTIME_GET_ISOLATE; | |
3094 NoHandleAllocation ha; | 3025 NoHandleAllocation ha; |
3095 ASSERT(args.length() == 2); | 3026 ASSERT(args.length() == 2); |
3096 | 3027 |
3097 CONVERT_CHECKED(String, str1, args[0]); | 3028 CONVERT_CHECKED(String, str1, args[0]); |
3098 CONVERT_CHECKED(String, str2, args[1]); | 3029 CONVERT_CHECKED(String, str2, args[1]); |
3099 | 3030 |
3100 if (str1 == str2) return Smi::FromInt(0); // Equal. | 3031 if (str1 == str2) return Smi::FromInt(0); // Equal. |
3101 int str1_length = str1->length(); | 3032 int str1_length = str1->length(); |
3102 int str2_length = str2->length(); | 3033 int str2_length = str2->length(); |
3103 | 3034 |
(...skipping 27 matching lines...) Expand all Loading... |
3131 for (int i = 0; i < end; i++) { | 3062 for (int i = 0; i < end; i++) { |
3132 uint16_t char1 = buf1.GetNext(); | 3063 uint16_t char1 = buf1.GetNext(); |
3133 uint16_t char2 = buf2.GetNext(); | 3064 uint16_t char2 = buf2.GetNext(); |
3134 if (char1 != char2) return Smi::FromInt(char1 - char2); | 3065 if (char1 != char2) return Smi::FromInt(char1 - char2); |
3135 } | 3066 } |
3136 | 3067 |
3137 return Smi::FromInt(str1_length - str2_length); | 3068 return Smi::FromInt(str1_length - str2_length); |
3138 } | 3069 } |
3139 | 3070 |
3140 | 3071 |
3141 static MaybeObject* Runtime_SubString(RUNTIME_CALLING_CONVENTION) { | 3072 RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) { |
3142 RUNTIME_GET_ISOLATE; | |
3143 NoHandleAllocation ha; | 3073 NoHandleAllocation ha; |
3144 ASSERT(args.length() == 3); | 3074 ASSERT(args.length() == 3); |
3145 | 3075 |
3146 CONVERT_CHECKED(String, value, args[0]); | 3076 CONVERT_CHECKED(String, value, args[0]); |
3147 Object* from = args[1]; | 3077 Object* from = args[1]; |
3148 Object* to = args[2]; | 3078 Object* to = args[2]; |
3149 int start, end; | 3079 int start, end; |
3150 // We have a fast integer-only case here to avoid a conversion to double in | 3080 // We have a fast integer-only case here to avoid a conversion to double in |
3151 // the common case where from and to are Smis. | 3081 // the common case where from and to are Smis. |
3152 if (from->IsSmi() && to->IsSmi()) { | 3082 if (from->IsSmi() && to->IsSmi()) { |
3153 start = Smi::cast(from)->value(); | 3083 start = Smi::cast(from)->value(); |
3154 end = Smi::cast(to)->value(); | 3084 end = Smi::cast(to)->value(); |
3155 } else { | 3085 } else { |
3156 CONVERT_DOUBLE_CHECKED(from_number, from); | 3086 CONVERT_DOUBLE_CHECKED(from_number, from); |
3157 CONVERT_DOUBLE_CHECKED(to_number, to); | 3087 CONVERT_DOUBLE_CHECKED(to_number, to); |
3158 start = FastD2I(from_number); | 3088 start = FastD2I(from_number); |
3159 end = FastD2I(to_number); | 3089 end = FastD2I(to_number); |
3160 } | 3090 } |
3161 RUNTIME_ASSERT(end >= start); | 3091 RUNTIME_ASSERT(end >= start); |
3162 RUNTIME_ASSERT(start >= 0); | 3092 RUNTIME_ASSERT(start >= 0); |
3163 RUNTIME_ASSERT(end <= value->length()); | 3093 RUNTIME_ASSERT(end <= value->length()); |
3164 isolate->counters()->sub_string_runtime()->Increment(); | 3094 isolate->counters()->sub_string_runtime()->Increment(); |
3165 return value->SubString(start, end); | 3095 return value->SubString(start, end); |
3166 } | 3096 } |
3167 | 3097 |
3168 | 3098 |
3169 static MaybeObject* Runtime_StringMatch(RUNTIME_CALLING_CONVENTION) { | 3099 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { |
3170 RUNTIME_GET_ISOLATE; | |
3171 ASSERT_EQ(3, args.length()); | 3100 ASSERT_EQ(3, args.length()); |
3172 | 3101 |
3173 CONVERT_ARG_CHECKED(String, subject, 0); | 3102 CONVERT_ARG_CHECKED(String, subject, 0); |
3174 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); | 3103 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); |
3175 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); | 3104 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); |
3176 HandleScope handles; | 3105 HandleScope handles; |
3177 | 3106 |
3178 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); | 3107 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); |
3179 | 3108 |
3180 if (match.is_null()) { | 3109 if (match.is_null()) { |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3526 RegExpImpl::SetCapture(elements, i, prev_register_vector[i]); | 3455 RegExpImpl::SetCapture(elements, i, prev_register_vector[i]); |
3527 } | 3456 } |
3528 return RegExpImpl::RE_SUCCESS; | 3457 return RegExpImpl::RE_SUCCESS; |
3529 } | 3458 } |
3530 } | 3459 } |
3531 // No matches at all, return failure or exception result directly. | 3460 // No matches at all, return failure or exception result directly. |
3532 return result; | 3461 return result; |
3533 } | 3462 } |
3534 | 3463 |
3535 | 3464 |
3536 static MaybeObject* Runtime_RegExpExecMultiple(RUNTIME_CALLING_CONVENTION) { | 3465 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) { |
3537 RUNTIME_GET_ISOLATE; | |
3538 ASSERT(args.length() == 4); | 3466 ASSERT(args.length() == 4); |
3539 HandleScope handles(isolate); | 3467 HandleScope handles(isolate); |
3540 | 3468 |
3541 CONVERT_ARG_CHECKED(String, subject, 1); | 3469 CONVERT_ARG_CHECKED(String, subject, 1); |
3542 if (!subject->IsFlat()) { FlattenString(subject); } | 3470 if (!subject->IsFlat()) { FlattenString(subject); } |
3543 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); | 3471 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); |
3544 CONVERT_ARG_CHECKED(JSArray, last_match_info, 2); | 3472 CONVERT_ARG_CHECKED(JSArray, last_match_info, 2); |
3545 CONVERT_ARG_CHECKED(JSArray, result_array, 3); | 3473 CONVERT_ARG_CHECKED(JSArray, result_array, 3); |
3546 | 3474 |
3547 ASSERT(last_match_info->HasFastElements()); | 3475 ASSERT(last_match_info->HasFastElements()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3582 last_match_info, | 3510 last_match_info, |
3583 &builder); | 3511 &builder); |
3584 } | 3512 } |
3585 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); | 3513 if (result == RegExpImpl::RE_SUCCESS) return *builder.ToJSArray(result_array); |
3586 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); | 3514 if (result == RegExpImpl::RE_FAILURE) return isolate->heap()->null_value(); |
3587 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); | 3515 ASSERT_EQ(result, RegExpImpl::RE_EXCEPTION); |
3588 return Failure::Exception(); | 3516 return Failure::Exception(); |
3589 } | 3517 } |
3590 | 3518 |
3591 | 3519 |
3592 static MaybeObject* Runtime_NumberToRadixString(RUNTIME_CALLING_CONVENTION) { | 3520 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { |
3593 RUNTIME_GET_ISOLATE; | |
3594 NoHandleAllocation ha; | 3521 NoHandleAllocation ha; |
3595 ASSERT(args.length() == 2); | 3522 ASSERT(args.length() == 2); |
3596 | 3523 |
3597 // Fast case where the result is a one character string. | 3524 // Fast case where the result is a one character string. |
3598 if (args[0]->IsSmi() && args[1]->IsSmi()) { | 3525 if (args[0]->IsSmi() && args[1]->IsSmi()) { |
3599 int value = Smi::cast(args[0])->value(); | 3526 int value = Smi::cast(args[0])->value(); |
3600 int radix = Smi::cast(args[1])->value(); | 3527 int radix = Smi::cast(args[1])->value(); |
3601 if (value >= 0 && value < radix) { | 3528 if (value >= 0 && value < radix) { |
3602 RUNTIME_ASSERT(radix <= 36); | 3529 RUNTIME_ASSERT(radix <= 36); |
3603 // Character array used for conversion. | 3530 // Character array used for conversion. |
(...skipping 18 matching lines...) Expand all Loading... |
3622 int radix = FastD2I(radix_number); | 3549 int radix = FastD2I(radix_number); |
3623 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 3550 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
3624 char* str = DoubleToRadixCString(value, radix); | 3551 char* str = DoubleToRadixCString(value, radix); |
3625 MaybeObject* result = | 3552 MaybeObject* result = |
3626 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 3553 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
3627 DeleteArray(str); | 3554 DeleteArray(str); |
3628 return result; | 3555 return result; |
3629 } | 3556 } |
3630 | 3557 |
3631 | 3558 |
3632 static MaybeObject* Runtime_NumberToFixed(RUNTIME_CALLING_CONVENTION) { | 3559 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { |
3633 RUNTIME_GET_ISOLATE; | |
3634 NoHandleAllocation ha; | 3560 NoHandleAllocation ha; |
3635 ASSERT(args.length() == 2); | 3561 ASSERT(args.length() == 2); |
3636 | 3562 |
3637 CONVERT_DOUBLE_CHECKED(value, args[0]); | 3563 CONVERT_DOUBLE_CHECKED(value, args[0]); |
3638 if (isnan(value)) { | 3564 if (isnan(value)) { |
3639 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); | 3565 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); |
3640 } | 3566 } |
3641 if (isinf(value)) { | 3567 if (isinf(value)) { |
3642 if (value < 0) { | 3568 if (value < 0) { |
3643 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); | 3569 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); |
3644 } | 3570 } |
3645 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); | 3571 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); |
3646 } | 3572 } |
3647 CONVERT_DOUBLE_CHECKED(f_number, args[1]); | 3573 CONVERT_DOUBLE_CHECKED(f_number, args[1]); |
3648 int f = FastD2I(f_number); | 3574 int f = FastD2I(f_number); |
3649 RUNTIME_ASSERT(f >= 0); | 3575 RUNTIME_ASSERT(f >= 0); |
3650 char* str = DoubleToFixedCString(value, f); | 3576 char* str = DoubleToFixedCString(value, f); |
3651 MaybeObject* res = | 3577 MaybeObject* res = |
3652 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 3578 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
3653 DeleteArray(str); | 3579 DeleteArray(str); |
3654 return res; | 3580 return res; |
3655 } | 3581 } |
3656 | 3582 |
3657 | 3583 |
3658 static MaybeObject* Runtime_NumberToExponential(RUNTIME_CALLING_CONVENTION) { | 3584 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { |
3659 RUNTIME_GET_ISOLATE; | |
3660 NoHandleAllocation ha; | 3585 NoHandleAllocation ha; |
3661 ASSERT(args.length() == 2); | 3586 ASSERT(args.length() == 2); |
3662 | 3587 |
3663 CONVERT_DOUBLE_CHECKED(value, args[0]); | 3588 CONVERT_DOUBLE_CHECKED(value, args[0]); |
3664 if (isnan(value)) { | 3589 if (isnan(value)) { |
3665 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); | 3590 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); |
3666 } | 3591 } |
3667 if (isinf(value)) { | 3592 if (isinf(value)) { |
3668 if (value < 0) { | 3593 if (value < 0) { |
3669 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); | 3594 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); |
3670 } | 3595 } |
3671 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); | 3596 return isolate->heap()->AllocateStringFromAscii(CStrVector("Infinity")); |
3672 } | 3597 } |
3673 CONVERT_DOUBLE_CHECKED(f_number, args[1]); | 3598 CONVERT_DOUBLE_CHECKED(f_number, args[1]); |
3674 int f = FastD2I(f_number); | 3599 int f = FastD2I(f_number); |
3675 RUNTIME_ASSERT(f >= -1 && f <= 20); | 3600 RUNTIME_ASSERT(f >= -1 && f <= 20); |
3676 char* str = DoubleToExponentialCString(value, f); | 3601 char* str = DoubleToExponentialCString(value, f); |
3677 MaybeObject* res = | 3602 MaybeObject* res = |
3678 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); | 3603 isolate->heap()->AllocateStringFromAscii(CStrVector(str)); |
3679 DeleteArray(str); | 3604 DeleteArray(str); |
3680 return res; | 3605 return res; |
3681 } | 3606 } |
3682 | 3607 |
3683 | 3608 |
3684 static MaybeObject* Runtime_NumberToPrecision(RUNTIME_CALLING_CONVENTION) { | 3609 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { |
3685 RUNTIME_GET_ISOLATE; | |
3686 NoHandleAllocation ha; | 3610 NoHandleAllocation ha; |
3687 ASSERT(args.length() == 2); | 3611 ASSERT(args.length() == 2); |
3688 | 3612 |
3689 CONVERT_DOUBLE_CHECKED(value, args[0]); | 3613 CONVERT_DOUBLE_CHECKED(value, args[0]); |
3690 if (isnan(value)) { | 3614 if (isnan(value)) { |
3691 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); | 3615 return isolate->heap()->AllocateStringFromAscii(CStrVector("NaN")); |
3692 } | 3616 } |
3693 if (isinf(value)) { | 3617 if (isinf(value)) { |
3694 if (value < 0) { | 3618 if (value < 0) { |
3695 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); | 3619 return isolate->heap()->AllocateStringFromAscii(CStrVector("-Infinity")); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3785 // the element if so. | 3709 // the element if so. |
3786 if (name->AsArrayIndex(&index)) { | 3710 if (name->AsArrayIndex(&index)) { |
3787 return GetElementOrCharAt(isolate, object, index); | 3711 return GetElementOrCharAt(isolate, object, index); |
3788 } else { | 3712 } else { |
3789 PropertyAttributes attr; | 3713 PropertyAttributes attr; |
3790 return object->GetProperty(*name, &attr); | 3714 return object->GetProperty(*name, &attr); |
3791 } | 3715 } |
3792 } | 3716 } |
3793 | 3717 |
3794 | 3718 |
3795 static MaybeObject* Runtime_GetProperty(RUNTIME_CALLING_CONVENTION) { | 3719 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { |
3796 RUNTIME_GET_ISOLATE; | |
3797 NoHandleAllocation ha; | 3720 NoHandleAllocation ha; |
3798 ASSERT(args.length() == 2); | 3721 ASSERT(args.length() == 2); |
3799 | 3722 |
3800 Handle<Object> object = args.at<Object>(0); | 3723 Handle<Object> object = args.at<Object>(0); |
3801 Handle<Object> key = args.at<Object>(1); | 3724 Handle<Object> key = args.at<Object>(1); |
3802 | 3725 |
3803 return Runtime::GetObjectProperty(isolate, object, key); | 3726 return Runtime::GetObjectProperty(isolate, object, key); |
3804 } | 3727 } |
3805 | 3728 |
3806 | 3729 |
3807 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. | 3730 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. |
3808 static MaybeObject* Runtime_KeyedGetProperty(RUNTIME_CALLING_CONVENTION) { | 3731 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { |
3809 RUNTIME_GET_ISOLATE; | |
3810 NoHandleAllocation ha; | 3732 NoHandleAllocation ha; |
3811 ASSERT(args.length() == 2); | 3733 ASSERT(args.length() == 2); |
3812 | 3734 |
3813 // Fast cases for getting named properties of the receiver JSObject | 3735 // Fast cases for getting named properties of the receiver JSObject |
3814 // itself. | 3736 // itself. |
3815 // | 3737 // |
3816 // The global proxy objects has to be excluded since LocalLookup on | 3738 // The global proxy objects has to be excluded since LocalLookup on |
3817 // the global proxy object can return a valid result even though the | 3739 // the global proxy object can return a valid result even though the |
3818 // global proxy object never has properties. This is the case | 3740 // global proxy object never has properties. This is the case |
3819 // because the global proxy object forwards everything to its hidden | 3741 // because the global proxy object forwards everything to its hidden |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3873 args.at<Object>(0), | 3795 args.at<Object>(0), |
3874 args.at<Object>(1)); | 3796 args.at<Object>(1)); |
3875 } | 3797 } |
3876 | 3798 |
3877 // Implements part of 8.12.9 DefineOwnProperty. | 3799 // Implements part of 8.12.9 DefineOwnProperty. |
3878 // There are 3 cases that lead here: | 3800 // There are 3 cases that lead here: |
3879 // Step 4b - define a new accessor property. | 3801 // Step 4b - define a new accessor property. |
3880 // Steps 9c & 12 - replace an existing data property with an accessor property. | 3802 // Steps 9c & 12 - replace an existing data property with an accessor property. |
3881 // Step 12 - update an existing accessor property with an accessor or generic | 3803 // Step 12 - update an existing accessor property with an accessor or generic |
3882 // descriptor. | 3804 // descriptor. |
3883 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty( | 3805 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { |
3884 RUNTIME_CALLING_CONVENTION) { | |
3885 RUNTIME_GET_ISOLATE; | |
3886 ASSERT(args.length() == 5); | 3806 ASSERT(args.length() == 5); |
3887 HandleScope scope(isolate); | 3807 HandleScope scope(isolate); |
3888 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 3808 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
3889 CONVERT_CHECKED(String, name, args[1]); | 3809 CONVERT_CHECKED(String, name, args[1]); |
3890 CONVERT_CHECKED(Smi, flag_setter, args[2]); | 3810 CONVERT_CHECKED(Smi, flag_setter, args[2]); |
3891 Object* fun = args[3]; | 3811 Object* fun = args[3]; |
3892 RUNTIME_ASSERT(fun->IsJSFunction() || fun->IsUndefined()); | 3812 RUNTIME_ASSERT(fun->IsJSFunction() || fun->IsUndefined()); |
3893 CONVERT_CHECKED(Smi, flag_attr, args[4]); | 3813 CONVERT_CHECKED(Smi, flag_attr, args[4]); |
3894 int unchecked = flag_attr->value(); | 3814 int unchecked = flag_attr->value(); |
3895 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 3815 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
(...skipping 16 matching lines...) Expand all Loading... |
3912 } | 3832 } |
3913 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); | 3833 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); |
3914 } | 3834 } |
3915 | 3835 |
3916 // Implements part of 8.12.9 DefineOwnProperty. | 3836 // Implements part of 8.12.9 DefineOwnProperty. |
3917 // There are 3 cases that lead here: | 3837 // There are 3 cases that lead here: |
3918 // Step 4a - define a new data property. | 3838 // Step 4a - define a new data property. |
3919 // Steps 9b & 12 - replace an existing accessor property with a data property. | 3839 // Steps 9b & 12 - replace an existing accessor property with a data property. |
3920 // Step 12 - update an existing data property with a data or generic | 3840 // Step 12 - update an existing data property with a data or generic |
3921 // descriptor. | 3841 // descriptor. |
3922 static MaybeObject* Runtime_DefineOrRedefineDataProperty( | 3842 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { |
3923 RUNTIME_CALLING_CONVENTION) { | |
3924 RUNTIME_GET_ISOLATE; | |
3925 ASSERT(args.length() == 4); | 3843 ASSERT(args.length() == 4); |
3926 HandleScope scope(isolate); | 3844 HandleScope scope(isolate); |
3927 CONVERT_ARG_CHECKED(JSObject, js_object, 0); | 3845 CONVERT_ARG_CHECKED(JSObject, js_object, 0); |
3928 CONVERT_ARG_CHECKED(String, name, 1); | 3846 CONVERT_ARG_CHECKED(String, name, 1); |
3929 Handle<Object> obj_value = args.at<Object>(2); | 3847 Handle<Object> obj_value = args.at<Object>(2); |
3930 | 3848 |
3931 CONVERT_CHECKED(Smi, flag, args[3]); | 3849 CONVERT_CHECKED(Smi, flag, args[3]); |
3932 int unchecked = flag->value(); | 3850 int unchecked = flag->value(); |
3933 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 3851 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
3934 | 3852 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4150 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 4068 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
4151 if (has_pending_exception) return Failure::Exception(); | 4069 if (has_pending_exception) return Failure::Exception(); |
4152 key_string = Handle<String>::cast(converted); | 4070 key_string = Handle<String>::cast(converted); |
4153 } | 4071 } |
4154 | 4072 |
4155 key_string->TryFlatten(); | 4073 key_string->TryFlatten(); |
4156 return js_object->DeleteProperty(*key_string, JSObject::FORCE_DELETION); | 4074 return js_object->DeleteProperty(*key_string, JSObject::FORCE_DELETION); |
4157 } | 4075 } |
4158 | 4076 |
4159 | 4077 |
4160 static MaybeObject* Runtime_SetProperty(RUNTIME_CALLING_CONVENTION) { | 4078 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
4161 RUNTIME_GET_ISOLATE; | |
4162 NoHandleAllocation ha; | 4079 NoHandleAllocation ha; |
4163 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 4080 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
4164 | 4081 |
4165 Handle<Object> object = args.at<Object>(0); | 4082 Handle<Object> object = args.at<Object>(0); |
4166 Handle<Object> key = args.at<Object>(1); | 4083 Handle<Object> key = args.at<Object>(1); |
4167 Handle<Object> value = args.at<Object>(2); | 4084 Handle<Object> value = args.at<Object>(2); |
4168 CONVERT_SMI_CHECKED(unchecked_attributes, args[3]); | 4085 CONVERT_SMI_CHECKED(unchecked_attributes, args[3]); |
4169 RUNTIME_ASSERT( | 4086 RUNTIME_ASSERT( |
4170 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4087 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4171 // Compute attributes. | 4088 // Compute attributes. |
(...skipping 12 matching lines...) Expand all Loading... |
4184 object, | 4101 object, |
4185 key, | 4102 key, |
4186 value, | 4103 value, |
4187 attributes, | 4104 attributes, |
4188 strict_mode); | 4105 strict_mode); |
4189 } | 4106 } |
4190 | 4107 |
4191 | 4108 |
4192 // Set a local property, even if it is READ_ONLY. If the property does not | 4109 // Set a local property, even if it is READ_ONLY. If the property does not |
4193 // exist, it will be added with attributes NONE. | 4110 // exist, it will be added with attributes NONE. |
4194 static MaybeObject* Runtime_IgnoreAttributesAndSetProperty( | 4111 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { |
4195 RUNTIME_CALLING_CONVENTION) { | |
4196 RUNTIME_GET_ISOLATE; | |
4197 NoHandleAllocation ha; | 4112 NoHandleAllocation ha; |
4198 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 4113 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
4199 CONVERT_CHECKED(JSObject, object, args[0]); | 4114 CONVERT_CHECKED(JSObject, object, args[0]); |
4200 CONVERT_CHECKED(String, name, args[1]); | 4115 CONVERT_CHECKED(String, name, args[1]); |
4201 // Compute attributes. | 4116 // Compute attributes. |
4202 PropertyAttributes attributes = NONE; | 4117 PropertyAttributes attributes = NONE; |
4203 if (args.length() == 4) { | 4118 if (args.length() == 4) { |
4204 CONVERT_CHECKED(Smi, value_obj, args[3]); | 4119 CONVERT_CHECKED(Smi, value_obj, args[3]); |
4205 int unchecked_value = value_obj->value(); | 4120 int unchecked_value = value_obj->value(); |
4206 // Only attribute bits should be set. | 4121 // Only attribute bits should be set. |
4207 RUNTIME_ASSERT( | 4122 RUNTIME_ASSERT( |
4208 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 4123 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
4209 attributes = static_cast<PropertyAttributes>(unchecked_value); | 4124 attributes = static_cast<PropertyAttributes>(unchecked_value); |
4210 } | 4125 } |
4211 | 4126 |
4212 return object-> | 4127 return object-> |
4213 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 4128 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
4214 } | 4129 } |
4215 | 4130 |
4216 | 4131 |
4217 static MaybeObject* Runtime_DeleteProperty(RUNTIME_CALLING_CONVENTION) { | 4132 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
4218 RUNTIME_GET_ISOLATE; | |
4219 NoHandleAllocation ha; | 4133 NoHandleAllocation ha; |
4220 ASSERT(args.length() == 3); | 4134 ASSERT(args.length() == 3); |
4221 | 4135 |
4222 CONVERT_CHECKED(JSObject, object, args[0]); | 4136 CONVERT_CHECKED(JSObject, object, args[0]); |
4223 CONVERT_CHECKED(String, key, args[1]); | 4137 CONVERT_CHECKED(String, key, args[1]); |
4224 CONVERT_SMI_CHECKED(strict, args[2]); | 4138 CONVERT_SMI_CHECKED(strict, args[2]); |
4225 return object->DeleteProperty(key, (strict == kStrictMode) | 4139 return object->DeleteProperty(key, (strict == kStrictMode) |
4226 ? JSObject::STRICT_DELETION | 4140 ? JSObject::STRICT_DELETION |
4227 : JSObject::NORMAL_DELETION); | 4141 : JSObject::NORMAL_DELETION); |
4228 } | 4142 } |
(...skipping 10 matching lines...) Expand all Loading... |
4239 if (proto->IsJSObject() && | 4153 if (proto->IsJSObject() && |
4240 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 4154 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
4241 return HasLocalPropertyImplementation(isolate, | 4155 return HasLocalPropertyImplementation(isolate, |
4242 Handle<JSObject>::cast(proto), | 4156 Handle<JSObject>::cast(proto), |
4243 key); | 4157 key); |
4244 } | 4158 } |
4245 return isolate->heap()->false_value(); | 4159 return isolate->heap()->false_value(); |
4246 } | 4160 } |
4247 | 4161 |
4248 | 4162 |
4249 static MaybeObject* Runtime_HasLocalProperty(RUNTIME_CALLING_CONVENTION) { | 4163 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { |
4250 RUNTIME_GET_ISOLATE; | |
4251 NoHandleAllocation ha; | 4164 NoHandleAllocation ha; |
4252 ASSERT(args.length() == 2); | 4165 ASSERT(args.length() == 2); |
4253 CONVERT_CHECKED(String, key, args[1]); | 4166 CONVERT_CHECKED(String, key, args[1]); |
4254 | 4167 |
4255 Object* obj = args[0]; | 4168 Object* obj = args[0]; |
4256 // Only JS objects can have properties. | 4169 // Only JS objects can have properties. |
4257 if (obj->IsJSObject()) { | 4170 if (obj->IsJSObject()) { |
4258 JSObject* object = JSObject::cast(obj); | 4171 JSObject* object = JSObject::cast(obj); |
4259 // Fast case - no interceptors. | 4172 // Fast case - no interceptors. |
4260 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value(); | 4173 if (object->HasRealNamedProperty(key)) return isolate->heap()->true_value(); |
4261 // Slow case. Either it's not there or we have an interceptor. We should | 4174 // Slow case. Either it's not there or we have an interceptor. We should |
4262 // have handles for this kind of deal. | 4175 // have handles for this kind of deal. |
4263 HandleScope scope(isolate); | 4176 HandleScope scope(isolate); |
4264 return HasLocalPropertyImplementation(isolate, | 4177 return HasLocalPropertyImplementation(isolate, |
4265 Handle<JSObject>(object), | 4178 Handle<JSObject>(object), |
4266 Handle<String>(key)); | 4179 Handle<String>(key)); |
4267 } else if (obj->IsString()) { | 4180 } else if (obj->IsString()) { |
4268 // Well, there is one exception: Handle [] on strings. | 4181 // Well, there is one exception: Handle [] on strings. |
4269 uint32_t index; | 4182 uint32_t index; |
4270 if (key->AsArrayIndex(&index)) { | 4183 if (key->AsArrayIndex(&index)) { |
4271 String* string = String::cast(obj); | 4184 String* string = String::cast(obj); |
4272 if (index < static_cast<uint32_t>(string->length())) | 4185 if (index < static_cast<uint32_t>(string->length())) |
4273 return isolate->heap()->true_value(); | 4186 return isolate->heap()->true_value(); |
4274 } | 4187 } |
4275 } | 4188 } |
4276 return isolate->heap()->false_value(); | 4189 return isolate->heap()->false_value(); |
4277 } | 4190 } |
4278 | 4191 |
4279 | 4192 |
4280 static MaybeObject* Runtime_HasProperty(RUNTIME_CALLING_CONVENTION) { | 4193 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { |
4281 RUNTIME_GET_ISOLATE; | |
4282 NoHandleAllocation na; | 4194 NoHandleAllocation na; |
4283 ASSERT(args.length() == 2); | 4195 ASSERT(args.length() == 2); |
4284 | 4196 |
4285 // Only JS objects can have properties. | 4197 // Only JS objects can have properties. |
4286 if (args[0]->IsJSObject()) { | 4198 if (args[0]->IsJSObject()) { |
4287 JSObject* object = JSObject::cast(args[0]); | 4199 JSObject* object = JSObject::cast(args[0]); |
4288 CONVERT_CHECKED(String, key, args[1]); | 4200 CONVERT_CHECKED(String, key, args[1]); |
4289 if (object->HasProperty(key)) return isolate->heap()->true_value(); | 4201 if (object->HasProperty(key)) return isolate->heap()->true_value(); |
4290 } | 4202 } |
4291 return isolate->heap()->false_value(); | 4203 return isolate->heap()->false_value(); |
4292 } | 4204 } |
4293 | 4205 |
4294 | 4206 |
4295 static MaybeObject* Runtime_HasElement(RUNTIME_CALLING_CONVENTION) { | 4207 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { |
4296 RUNTIME_GET_ISOLATE; | |
4297 NoHandleAllocation na; | 4208 NoHandleAllocation na; |
4298 ASSERT(args.length() == 2); | 4209 ASSERT(args.length() == 2); |
4299 | 4210 |
4300 // Only JS objects can have elements. | 4211 // Only JS objects can have elements. |
4301 if (args[0]->IsJSObject()) { | 4212 if (args[0]->IsJSObject()) { |
4302 JSObject* object = JSObject::cast(args[0]); | 4213 JSObject* object = JSObject::cast(args[0]); |
4303 CONVERT_CHECKED(Smi, index_obj, args[1]); | 4214 CONVERT_CHECKED(Smi, index_obj, args[1]); |
4304 uint32_t index = index_obj->value(); | 4215 uint32_t index = index_obj->value(); |
4305 if (object->HasElement(index)) return isolate->heap()->true_value(); | 4216 if (object->HasElement(index)) return isolate->heap()->true_value(); |
4306 } | 4217 } |
4307 return isolate->heap()->false_value(); | 4218 return isolate->heap()->false_value(); |
4308 } | 4219 } |
4309 | 4220 |
4310 | 4221 |
4311 static MaybeObject* Runtime_IsPropertyEnumerable(RUNTIME_CALLING_CONVENTION) { | 4222 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { |
4312 RUNTIME_GET_ISOLATE; | |
4313 NoHandleAllocation ha; | 4223 NoHandleAllocation ha; |
4314 ASSERT(args.length() == 2); | 4224 ASSERT(args.length() == 2); |
4315 | 4225 |
4316 CONVERT_CHECKED(JSObject, object, args[0]); | 4226 CONVERT_CHECKED(JSObject, object, args[0]); |
4317 CONVERT_CHECKED(String, key, args[1]); | 4227 CONVERT_CHECKED(String, key, args[1]); |
4318 | 4228 |
4319 uint32_t index; | 4229 uint32_t index; |
4320 if (key->AsArrayIndex(&index)) { | 4230 if (key->AsArrayIndex(&index)) { |
4321 return isolate->heap()->ToBoolean(object->HasElement(index)); | 4231 return isolate->heap()->ToBoolean(object->HasElement(index)); |
4322 } | 4232 } |
4323 | 4233 |
4324 PropertyAttributes att = object->GetLocalPropertyAttribute(key); | 4234 PropertyAttributes att = object->GetLocalPropertyAttribute(key); |
4325 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); | 4235 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); |
4326 } | 4236 } |
4327 | 4237 |
4328 | 4238 |
4329 static MaybeObject* Runtime_GetPropertyNames(RUNTIME_CALLING_CONVENTION) { | 4239 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { |
4330 RUNTIME_GET_ISOLATE; | |
4331 HandleScope scope(isolate); | 4240 HandleScope scope(isolate); |
4332 ASSERT(args.length() == 1); | 4241 ASSERT(args.length() == 1); |
4333 CONVERT_ARG_CHECKED(JSObject, object, 0); | 4242 CONVERT_ARG_CHECKED(JSObject, object, 0); |
4334 return *GetKeysFor(object); | 4243 return *GetKeysFor(object); |
4335 } | 4244 } |
4336 | 4245 |
4337 | 4246 |
4338 // Returns either a FixedArray as Runtime_GetPropertyNames, | 4247 // Returns either a FixedArray as Runtime_GetPropertyNames, |
4339 // or, if the given object has an enum cache that contains | 4248 // or, if the given object has an enum cache that contains |
4340 // all enumerable properties of the object and its prototypes | 4249 // all enumerable properties of the object and its prototypes |
4341 // have none, the map of the object. This is used to speed up | 4250 // have none, the map of the object. This is used to speed up |
4342 // the check for deletions during a for-in. | 4251 // the check for deletions during a for-in. |
4343 static MaybeObject* Runtime_GetPropertyNamesFast(RUNTIME_CALLING_CONVENTION) { | 4252 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { |
4344 RUNTIME_GET_ISOLATE; | |
4345 ASSERT(args.length() == 1); | 4253 ASSERT(args.length() == 1); |
4346 | 4254 |
4347 CONVERT_CHECKED(JSObject, raw_object, args[0]); | 4255 CONVERT_CHECKED(JSObject, raw_object, args[0]); |
4348 | 4256 |
4349 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 4257 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
4350 | 4258 |
4351 HandleScope scope(isolate); | 4259 HandleScope scope(isolate); |
4352 Handle<JSObject> object(raw_object); | 4260 Handle<JSObject> object(raw_object); |
4353 Handle<FixedArray> content = GetKeysInFixedArrayFor(object, | 4261 Handle<FixedArray> content = GetKeysInFixedArrayFor(object, |
4354 INCLUDE_PROTOS); | 4262 INCLUDE_PROTOS); |
(...skipping 15 matching lines...) Expand all Loading... |
4370 JSObject::cast(proto)->map()->is_hidden_prototype()) { | 4278 JSObject::cast(proto)->map()->is_hidden_prototype()) { |
4371 count++; | 4279 count++; |
4372 proto = JSObject::cast(proto)->GetPrototype(); | 4280 proto = JSObject::cast(proto)->GetPrototype(); |
4373 } | 4281 } |
4374 return count; | 4282 return count; |
4375 } | 4283 } |
4376 | 4284 |
4377 | 4285 |
4378 // Return the names of the local named properties. | 4286 // Return the names of the local named properties. |
4379 // args[0]: object | 4287 // args[0]: object |
4380 static MaybeObject* Runtime_GetLocalPropertyNames(RUNTIME_CALLING_CONVENTION) { | 4288 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { |
4381 RUNTIME_GET_ISOLATE; | |
4382 HandleScope scope(isolate); | 4289 HandleScope scope(isolate); |
4383 ASSERT(args.length() == 1); | 4290 ASSERT(args.length() == 1); |
4384 if (!args[0]->IsJSObject()) { | 4291 if (!args[0]->IsJSObject()) { |
4385 return isolate->heap()->undefined_value(); | 4292 return isolate->heap()->undefined_value(); |
4386 } | 4293 } |
4387 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4294 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4388 | 4295 |
4389 // Skip the global proxy as it has no properties and always delegates to the | 4296 // Skip the global proxy as it has no properties and always delegates to the |
4390 // real global object. | 4297 // real global object. |
4391 if (obj->IsJSGlobalProxy()) { | 4298 if (obj->IsJSGlobalProxy()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4457 names->set(dest_pos++, name); | 4364 names->set(dest_pos++, name); |
4458 } | 4365 } |
4459 } | 4366 } |
4460 | 4367 |
4461 return *isolate->factory()->NewJSArrayWithElements(names); | 4368 return *isolate->factory()->NewJSArrayWithElements(names); |
4462 } | 4369 } |
4463 | 4370 |
4464 | 4371 |
4465 // Return the names of the local indexed properties. | 4372 // Return the names of the local indexed properties. |
4466 // args[0]: object | 4373 // args[0]: object |
4467 static MaybeObject* Runtime_GetLocalElementNames(RUNTIME_CALLING_CONVENTION) { | 4374 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) { |
4468 RUNTIME_GET_ISOLATE; | |
4469 HandleScope scope(isolate); | 4375 HandleScope scope(isolate); |
4470 ASSERT(args.length() == 1); | 4376 ASSERT(args.length() == 1); |
4471 if (!args[0]->IsJSObject()) { | 4377 if (!args[0]->IsJSObject()) { |
4472 return isolate->heap()->undefined_value(); | 4378 return isolate->heap()->undefined_value(); |
4473 } | 4379 } |
4474 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4380 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4475 | 4381 |
4476 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); | 4382 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); |
4477 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); | 4383 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
4478 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); | 4384 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); |
4479 return *isolate->factory()->NewJSArrayWithElements(names); | 4385 return *isolate->factory()->NewJSArrayWithElements(names); |
4480 } | 4386 } |
4481 | 4387 |
4482 | 4388 |
4483 // Return information on whether an object has a named or indexed interceptor. | 4389 // Return information on whether an object has a named or indexed interceptor. |
4484 // args[0]: object | 4390 // args[0]: object |
4485 static MaybeObject* Runtime_GetInterceptorInfo(RUNTIME_CALLING_CONVENTION) { | 4391 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetInterceptorInfo) { |
4486 RUNTIME_GET_ISOLATE; | |
4487 HandleScope scope(isolate); | 4392 HandleScope scope(isolate); |
4488 ASSERT(args.length() == 1); | 4393 ASSERT(args.length() == 1); |
4489 if (!args[0]->IsJSObject()) { | 4394 if (!args[0]->IsJSObject()) { |
4490 return Smi::FromInt(0); | 4395 return Smi::FromInt(0); |
4491 } | 4396 } |
4492 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4397 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4493 | 4398 |
4494 int result = 0; | 4399 int result = 0; |
4495 if (obj->HasNamedInterceptor()) result |= 2; | 4400 if (obj->HasNamedInterceptor()) result |= 2; |
4496 if (obj->HasIndexedInterceptor()) result |= 1; | 4401 if (obj->HasIndexedInterceptor()) result |= 1; |
4497 | 4402 |
4498 return Smi::FromInt(result); | 4403 return Smi::FromInt(result); |
4499 } | 4404 } |
4500 | 4405 |
4501 | 4406 |
4502 // Return property names from named interceptor. | 4407 // Return property names from named interceptor. |
4503 // args[0]: object | 4408 // args[0]: object |
4504 static MaybeObject* Runtime_GetNamedInterceptorPropertyNames( | 4409 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) { |
4505 RUNTIME_CALLING_CONVENTION) { | |
4506 RUNTIME_GET_ISOLATE; | |
4507 HandleScope scope(isolate); | 4410 HandleScope scope(isolate); |
4508 ASSERT(args.length() == 1); | 4411 ASSERT(args.length() == 1); |
4509 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4412 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4510 | 4413 |
4511 if (obj->HasNamedInterceptor()) { | 4414 if (obj->HasNamedInterceptor()) { |
4512 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj); | 4415 v8::Handle<v8::Array> result = GetKeysForNamedInterceptor(obj, obj); |
4513 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 4416 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
4514 } | 4417 } |
4515 return isolate->heap()->undefined_value(); | 4418 return isolate->heap()->undefined_value(); |
4516 } | 4419 } |
4517 | 4420 |
4518 | 4421 |
4519 // Return element names from indexed interceptor. | 4422 // Return element names from indexed interceptor. |
4520 // args[0]: object | 4423 // args[0]: object |
4521 static MaybeObject* Runtime_GetIndexedInterceptorElementNames( | 4424 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) { |
4522 RUNTIME_CALLING_CONVENTION) { | |
4523 RUNTIME_GET_ISOLATE; | |
4524 HandleScope scope(isolate); | 4425 HandleScope scope(isolate); |
4525 ASSERT(args.length() == 1); | 4426 ASSERT(args.length() == 1); |
4526 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 4427 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
4527 | 4428 |
4528 if (obj->HasIndexedInterceptor()) { | 4429 if (obj->HasIndexedInterceptor()) { |
4529 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); | 4430 v8::Handle<v8::Array> result = GetKeysForIndexedInterceptor(obj, obj); |
4530 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); | 4431 if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result); |
4531 } | 4432 } |
4532 return isolate->heap()->undefined_value(); | 4433 return isolate->heap()->undefined_value(); |
4533 } | 4434 } |
4534 | 4435 |
4535 | 4436 |
4536 static MaybeObject* Runtime_LocalKeys(RUNTIME_CALLING_CONVENTION) { | 4437 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { |
4537 RUNTIME_GET_ISOLATE; | |
4538 ASSERT_EQ(args.length(), 1); | 4438 ASSERT_EQ(args.length(), 1); |
4539 CONVERT_CHECKED(JSObject, raw_object, args[0]); | 4439 CONVERT_CHECKED(JSObject, raw_object, args[0]); |
4540 HandleScope scope(isolate); | 4440 HandleScope scope(isolate); |
4541 Handle<JSObject> object(raw_object); | 4441 Handle<JSObject> object(raw_object); |
4542 | 4442 |
4543 if (object->IsJSGlobalProxy()) { | 4443 if (object->IsJSGlobalProxy()) { |
4544 // Do access checks before going to the global object. | 4444 // Do access checks before going to the global object. |
4545 if (object->IsAccessCheckNeeded() && | 4445 if (object->IsAccessCheckNeeded() && |
4546 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), | 4446 !isolate->MayNamedAccess(*object, isolate->heap()->undefined_value(), |
4547 v8::ACCESS_KEYS)) { | 4447 v8::ACCESS_KEYS)) { |
(...skipping 24 matching lines...) Expand all Loading... |
4572 Handle<Object> entry_handle(entry, isolate); | 4472 Handle<Object> entry_handle(entry, isolate); |
4573 Handle<Object> entry_str = | 4473 Handle<Object> entry_str = |
4574 isolate->factory()->NumberToString(entry_handle); | 4474 isolate->factory()->NumberToString(entry_handle); |
4575 copy->set(i, *entry_str); | 4475 copy->set(i, *entry_str); |
4576 } | 4476 } |
4577 } | 4477 } |
4578 return *isolate->factory()->NewJSArrayWithElements(copy); | 4478 return *isolate->factory()->NewJSArrayWithElements(copy); |
4579 } | 4479 } |
4580 | 4480 |
4581 | 4481 |
4582 static MaybeObject* Runtime_GetArgumentsProperty(RUNTIME_CALLING_CONVENTION) { | 4482 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { |
4583 RUNTIME_GET_ISOLATE; | |
4584 NoHandleAllocation ha; | 4483 NoHandleAllocation ha; |
4585 ASSERT(args.length() == 1); | 4484 ASSERT(args.length() == 1); |
4586 | 4485 |
4587 // Compute the frame holding the arguments. | 4486 // Compute the frame holding the arguments. |
4588 JavaScriptFrameIterator it; | 4487 JavaScriptFrameIterator it; |
4589 it.AdvanceToArgumentsFrame(); | 4488 it.AdvanceToArgumentsFrame(); |
4590 JavaScriptFrame* frame = it.frame(); | 4489 JavaScriptFrame* frame = it.frame(); |
4591 | 4490 |
4592 // Get the actual number of provided arguments. | 4491 // Get the actual number of provided arguments. |
4593 const uint32_t n = frame->ComputeParametersCount(); | 4492 const uint32_t n = frame->ComputeParametersCount(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4626 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); | 4525 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); |
4627 } | 4526 } |
4628 return function; | 4527 return function; |
4629 } | 4528 } |
4630 | 4529 |
4631 // Lookup in the initial Object.prototype object. | 4530 // Lookup in the initial Object.prototype object. |
4632 return isolate->initial_object_prototype()->GetProperty(*key); | 4531 return isolate->initial_object_prototype()->GetProperty(*key); |
4633 } | 4532 } |
4634 | 4533 |
4635 | 4534 |
4636 static MaybeObject* Runtime_ToFastProperties(RUNTIME_CALLING_CONVENTION) { | 4535 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { |
4637 RUNTIME_GET_ISOLATE; | |
4638 HandleScope scope(isolate); | 4536 HandleScope scope(isolate); |
4639 | 4537 |
4640 ASSERT(args.length() == 1); | 4538 ASSERT(args.length() == 1); |
4641 Handle<Object> object = args.at<Object>(0); | 4539 Handle<Object> object = args.at<Object>(0); |
4642 if (object->IsJSObject()) { | 4540 if (object->IsJSObject()) { |
4643 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 4541 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
4644 if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) { | 4542 if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) { |
4645 MaybeObject* ok = js_object->TransformToFastProperties(0); | 4543 MaybeObject* ok = js_object->TransformToFastProperties(0); |
4646 if (ok->IsRetryAfterGC()) return ok; | 4544 if (ok->IsRetryAfterGC()) return ok; |
4647 } | 4545 } |
4648 } | 4546 } |
4649 return *object; | 4547 return *object; |
4650 } | 4548 } |
4651 | 4549 |
4652 | 4550 |
4653 static MaybeObject* Runtime_ToSlowProperties(RUNTIME_CALLING_CONVENTION) { | 4551 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToSlowProperties) { |
4654 RUNTIME_GET_ISOLATE; | |
4655 HandleScope scope(isolate); | 4552 HandleScope scope(isolate); |
4656 | 4553 |
4657 ASSERT(args.length() == 1); | 4554 ASSERT(args.length() == 1); |
4658 Handle<Object> object = args.at<Object>(0); | 4555 Handle<Object> object = args.at<Object>(0); |
4659 if (object->IsJSObject() && !object->IsJSGlobalProxy()) { | 4556 if (object->IsJSObject() && !object->IsJSGlobalProxy()) { |
4660 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 4557 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
4661 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 4558 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
4662 } | 4559 } |
4663 return *object; | 4560 return *object; |
4664 } | 4561 } |
4665 | 4562 |
4666 | 4563 |
4667 static MaybeObject* Runtime_ToBool(RUNTIME_CALLING_CONVENTION) { | 4564 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { |
4668 RUNTIME_GET_ISOLATE; | |
4669 NoHandleAllocation ha; | 4565 NoHandleAllocation ha; |
4670 ASSERT(args.length() == 1); | 4566 ASSERT(args.length() == 1); |
4671 | 4567 |
4672 return args[0]->ToBoolean(); | 4568 return args[0]->ToBoolean(); |
4673 } | 4569 } |
4674 | 4570 |
4675 | 4571 |
4676 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 4572 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
4677 // Possible optimizations: put the type string into the oddballs. | 4573 // Possible optimizations: put the type string into the oddballs. |
4678 static MaybeObject* Runtime_Typeof(RUNTIME_CALLING_CONVENTION) { | 4574 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { |
4679 RUNTIME_GET_ISOLATE; | |
4680 NoHandleAllocation ha; | 4575 NoHandleAllocation ha; |
4681 | 4576 |
4682 Object* obj = args[0]; | 4577 Object* obj = args[0]; |
4683 if (obj->IsNumber()) return isolate->heap()->number_symbol(); | 4578 if (obj->IsNumber()) return isolate->heap()->number_symbol(); |
4684 HeapObject* heap_obj = HeapObject::cast(obj); | 4579 HeapObject* heap_obj = HeapObject::cast(obj); |
4685 | 4580 |
4686 // typeof an undetectable object is 'undefined' | 4581 // typeof an undetectable object is 'undefined' |
4687 if (heap_obj->map()->is_undetectable()) { | 4582 if (heap_obj->map()->is_undetectable()) { |
4688 return isolate->heap()->undefined_symbol(); | 4583 return isolate->heap()->undefined_symbol(); |
4689 } | 4584 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4728 int d = s[from] - '0'; | 4623 int d = s[from] - '0'; |
4729 | 4624 |
4730 for (int i = from + 1; i < to; i++) { | 4625 for (int i = from + 1; i < to; i++) { |
4731 d = 10 * d + (s[i] - '0'); | 4626 d = 10 * d + (s[i] - '0'); |
4732 } | 4627 } |
4733 | 4628 |
4734 return d; | 4629 return d; |
4735 } | 4630 } |
4736 | 4631 |
4737 | 4632 |
4738 static MaybeObject* Runtime_StringToNumber(RUNTIME_CALLING_CONVENTION) { | 4633 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { |
4739 RUNTIME_GET_ISOLATE; | |
4740 NoHandleAllocation ha; | 4634 NoHandleAllocation ha; |
4741 ASSERT(args.length() == 1); | 4635 ASSERT(args.length() == 1); |
4742 CONVERT_CHECKED(String, subject, args[0]); | 4636 CONVERT_CHECKED(String, subject, args[0]); |
4743 subject->TryFlatten(); | 4637 subject->TryFlatten(); |
4744 | 4638 |
4745 // Fast case: short integer or some sorts of junk values. | 4639 // Fast case: short integer or some sorts of junk values. |
4746 int len = subject->length(); | 4640 int len = subject->length(); |
4747 if (subject->IsSeqAsciiString()) { | 4641 if (subject->IsSeqAsciiString()) { |
4748 if (len == 0) return Smi::FromInt(0); | 4642 if (len == 0) return Smi::FromInt(0); |
4749 | 4643 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4783 } | 4677 } |
4784 return Smi::FromInt(d); | 4678 return Smi::FromInt(d); |
4785 } | 4679 } |
4786 } | 4680 } |
4787 | 4681 |
4788 // Slower case. | 4682 // Slower case. |
4789 return isolate->heap()->NumberFromDouble(StringToDouble(subject, ALLOW_HEX)); | 4683 return isolate->heap()->NumberFromDouble(StringToDouble(subject, ALLOW_HEX)); |
4790 } | 4684 } |
4791 | 4685 |
4792 | 4686 |
4793 static MaybeObject* Runtime_StringFromCharCodeArray( | 4687 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringFromCharCodeArray) { |
4794 RUNTIME_CALLING_CONVENTION) { | |
4795 RUNTIME_GET_ISOLATE; | |
4796 NoHandleAllocation ha; | 4688 NoHandleAllocation ha; |
4797 ASSERT(args.length() == 1); | 4689 ASSERT(args.length() == 1); |
4798 | 4690 |
4799 CONVERT_CHECKED(JSArray, codes, args[0]); | 4691 CONVERT_CHECKED(JSArray, codes, args[0]); |
4800 int length = Smi::cast(codes->length())->value(); | 4692 int length = Smi::cast(codes->length())->value(); |
4801 | 4693 |
4802 // Check if the string can be ASCII. | 4694 // Check if the string can be ASCII. |
4803 int i; | 4695 int i; |
4804 for (i = 0; i < length; i++) { | 4696 for (i = 0; i < length; i++) { |
4805 Object* element; | 4697 Object* element; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4865 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 4757 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4866 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 4758 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4867 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 4759 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4868 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 4760 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4869 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 4761 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
4870 }; | 4762 }; |
4871 return kNotEscaped[character] != 0; | 4763 return kNotEscaped[character] != 0; |
4872 } | 4764 } |
4873 | 4765 |
4874 | 4766 |
4875 static MaybeObject* Runtime_URIEscape(RUNTIME_CALLING_CONVENTION) { | 4767 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { |
4876 RUNTIME_GET_ISOLATE; | |
4877 const char hex_chars[] = "0123456789ABCDEF"; | 4768 const char hex_chars[] = "0123456789ABCDEF"; |
4878 NoHandleAllocation ha; | 4769 NoHandleAllocation ha; |
4879 ASSERT(args.length() == 1); | 4770 ASSERT(args.length() == 1); |
4880 CONVERT_CHECKED(String, source, args[0]); | 4771 CONVERT_CHECKED(String, source, args[0]); |
4881 | 4772 |
4882 source->TryFlatten(); | 4773 source->TryFlatten(); |
4883 | 4774 |
4884 int escaped_length = 0; | 4775 int escaped_length = 0; |
4885 int length = source->length(); | 4776 int length = source->length(); |
4886 { | 4777 { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4985 source->Get(i + 2))) != -1) { | 4876 source->Get(i + 2))) != -1) { |
4986 *step = 3; | 4877 *step = 3; |
4987 return lo; | 4878 return lo; |
4988 } else { | 4879 } else { |
4989 *step = 1; | 4880 *step = 1; |
4990 return character; | 4881 return character; |
4991 } | 4882 } |
4992 } | 4883 } |
4993 | 4884 |
4994 | 4885 |
4995 static MaybeObject* Runtime_URIUnescape(RUNTIME_CALLING_CONVENTION) { | 4886 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { |
4996 RUNTIME_GET_ISOLATE; | |
4997 NoHandleAllocation ha; | 4887 NoHandleAllocation ha; |
4998 ASSERT(args.length() == 1); | 4888 ASSERT(args.length() == 1); |
4999 CONVERT_CHECKED(String, source, args[0]); | 4889 CONVERT_CHECKED(String, source, args[0]); |
5000 | 4890 |
5001 source->TryFlatten(); | 4891 source->TryFlatten(); |
5002 | 4892 |
5003 bool ascii = true; | 4893 bool ascii = true; |
5004 int length = source->length(); | 4894 int length = source->length(); |
5005 | 4895 |
5006 int unescaped_length = 0; | 4896 int unescaped_length = 0; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5230 int final_length = static_cast<int>( | 5120 int final_length = static_cast<int>( |
5231 write_cursor - reinterpret_cast<Char*>( | 5121 write_cursor - reinterpret_cast<Char*>( |
5232 new_string->address() + SeqAsciiString::kHeaderSize)); | 5122 new_string->address() + SeqAsciiString::kHeaderSize)); |
5233 isolate->heap()->new_space()-> | 5123 isolate->heap()->new_space()-> |
5234 template ShrinkStringAtAllocationBoundary<StringType>( | 5124 template ShrinkStringAtAllocationBoundary<StringType>( |
5235 new_string, final_length); | 5125 new_string, final_length); |
5236 return new_string; | 5126 return new_string; |
5237 } | 5127 } |
5238 | 5128 |
5239 | 5129 |
5240 static MaybeObject* Runtime_QuoteJSONString(RUNTIME_CALLING_CONVENTION) { | 5130 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { |
5241 RUNTIME_GET_ISOLATE; | |
5242 NoHandleAllocation ha; | 5131 NoHandleAllocation ha; |
5243 CONVERT_CHECKED(String, str, args[0]); | 5132 CONVERT_CHECKED(String, str, args[0]); |
5244 if (!str->IsFlat()) { | 5133 if (!str->IsFlat()) { |
5245 MaybeObject* try_flatten = str->TryFlatten(); | 5134 MaybeObject* try_flatten = str->TryFlatten(); |
5246 Object* flat; | 5135 Object* flat; |
5247 if (!try_flatten->ToObject(&flat)) { | 5136 if (!try_flatten->ToObject(&flat)) { |
5248 return try_flatten; | 5137 return try_flatten; |
5249 } | 5138 } |
5250 str = String::cast(flat); | 5139 str = String::cast(flat); |
5251 ASSERT(str->IsFlat()); | 5140 ASSERT(str->IsFlat()); |
5252 } | 5141 } |
5253 if (str->IsTwoByteRepresentation()) { | 5142 if (str->IsTwoByteRepresentation()) { |
5254 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, | 5143 return QuoteJsonString<uc16, SeqTwoByteString, false>(isolate, |
5255 str->ToUC16Vector()); | 5144 str->ToUC16Vector()); |
5256 } else { | 5145 } else { |
5257 return QuoteJsonString<char, SeqAsciiString, false>(isolate, | 5146 return QuoteJsonString<char, SeqAsciiString, false>(isolate, |
5258 str->ToAsciiVector()); | 5147 str->ToAsciiVector()); |
5259 } | 5148 } |
5260 } | 5149 } |
5261 | 5150 |
5262 | 5151 |
5263 static MaybeObject* Runtime_QuoteJSONStringComma(RUNTIME_CALLING_CONVENTION) { | 5152 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONStringComma) { |
5264 RUNTIME_GET_ISOLATE; | |
5265 NoHandleAllocation ha; | 5153 NoHandleAllocation ha; |
5266 CONVERT_CHECKED(String, str, args[0]); | 5154 CONVERT_CHECKED(String, str, args[0]); |
5267 if (!str->IsFlat()) { | 5155 if (!str->IsFlat()) { |
5268 MaybeObject* try_flatten = str->TryFlatten(); | 5156 MaybeObject* try_flatten = str->TryFlatten(); |
5269 Object* flat; | 5157 Object* flat; |
5270 if (!try_flatten->ToObject(&flat)) { | 5158 if (!try_flatten->ToObject(&flat)) { |
5271 return try_flatten; | 5159 return try_flatten; |
5272 } | 5160 } |
5273 str = String::cast(flat); | 5161 str = String::cast(flat); |
5274 ASSERT(str->IsFlat()); | 5162 ASSERT(str->IsFlat()); |
5275 } | 5163 } |
5276 if (str->IsTwoByteRepresentation()) { | 5164 if (str->IsTwoByteRepresentation()) { |
5277 return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate, | 5165 return QuoteJsonString<uc16, SeqTwoByteString, true>(isolate, |
5278 str->ToUC16Vector()); | 5166 str->ToUC16Vector()); |
5279 } else { | 5167 } else { |
5280 return QuoteJsonString<char, SeqAsciiString, true>(isolate, | 5168 return QuoteJsonString<char, SeqAsciiString, true>(isolate, |
5281 str->ToAsciiVector()); | 5169 str->ToAsciiVector()); |
5282 } | 5170 } |
5283 } | 5171 } |
5284 | 5172 |
5285 static MaybeObject* Runtime_StringParseInt(RUNTIME_CALLING_CONVENTION) { | 5173 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { |
5286 RUNTIME_GET_ISOLATE; | |
5287 NoHandleAllocation ha; | 5174 NoHandleAllocation ha; |
5288 | 5175 |
5289 CONVERT_CHECKED(String, s, args[0]); | 5176 CONVERT_CHECKED(String, s, args[0]); |
5290 CONVERT_SMI_CHECKED(radix, args[1]); | 5177 CONVERT_SMI_CHECKED(radix, args[1]); |
5291 | 5178 |
5292 s->TryFlatten(); | 5179 s->TryFlatten(); |
5293 | 5180 |
5294 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 5181 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
5295 double value = StringToInt(s, radix); | 5182 double value = StringToInt(s, radix); |
5296 return isolate->heap()->NumberFromDouble(value); | 5183 return isolate->heap()->NumberFromDouble(value); |
5297 } | 5184 } |
5298 | 5185 |
5299 | 5186 |
5300 static MaybeObject* Runtime_StringParseFloat(RUNTIME_CALLING_CONVENTION) { | 5187 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { |
5301 RUNTIME_GET_ISOLATE; | |
5302 NoHandleAllocation ha; | 5188 NoHandleAllocation ha; |
5303 CONVERT_CHECKED(String, str, args[0]); | 5189 CONVERT_CHECKED(String, str, args[0]); |
5304 | 5190 |
5305 // ECMA-262 section 15.1.2.3, empty string is NaN | 5191 // ECMA-262 section 15.1.2.3, empty string is NaN |
5306 double value = StringToDouble(str, ALLOW_TRAILING_JUNK, OS::nan_value()); | 5192 double value = StringToDouble(str, ALLOW_TRAILING_JUNK, OS::nan_value()); |
5307 | 5193 |
5308 // Create a number object from the value. | 5194 // Create a number object from the value. |
5309 return isolate->heap()->NumberFromDouble(value); | 5195 return isolate->heap()->NumberFromDouble(value); |
5310 } | 5196 } |
5311 | 5197 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 { MaybeObject* maybe_answer = | 5468 { MaybeObject* maybe_answer = |
5583 ConvertCaseHelper(isolate, | 5469 ConvertCaseHelper(isolate, |
5584 s, Smi::cast(answer)->value(), length, mapping); | 5470 s, Smi::cast(answer)->value(), length, mapping); |
5585 if (!maybe_answer->ToObject(&answer)) return maybe_answer; | 5471 if (!maybe_answer->ToObject(&answer)) return maybe_answer; |
5586 } | 5472 } |
5587 } | 5473 } |
5588 return answer; | 5474 return answer; |
5589 } | 5475 } |
5590 | 5476 |
5591 | 5477 |
5592 static MaybeObject* Runtime_StringToLowerCase(RUNTIME_CALLING_CONVENTION) { | 5478 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) { |
5593 RUNTIME_GET_ISOLATE; | |
5594 return ConvertCase<ToLowerTraits>( | 5479 return ConvertCase<ToLowerTraits>( |
5595 args, isolate, isolate->runtime_state()->to_lower_mapping()); | 5480 args, isolate, isolate->runtime_state()->to_lower_mapping()); |
5596 } | 5481 } |
5597 | 5482 |
5598 | 5483 |
5599 static MaybeObject* Runtime_StringToUpperCase(RUNTIME_CALLING_CONVENTION) { | 5484 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) { |
5600 RUNTIME_GET_ISOLATE; | |
5601 return ConvertCase<ToUpperTraits>( | 5485 return ConvertCase<ToUpperTraits>( |
5602 args, isolate, isolate->runtime_state()->to_upper_mapping()); | 5486 args, isolate, isolate->runtime_state()->to_upper_mapping()); |
5603 } | 5487 } |
5604 | 5488 |
5605 | 5489 |
5606 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { | 5490 static inline bool IsTrimWhiteSpace(unibrow::uchar c) { |
5607 return unibrow::WhiteSpace::Is(c) || c == 0x200b; | 5491 return unibrow::WhiteSpace::Is(c) || c == 0x200b; |
5608 } | 5492 } |
5609 | 5493 |
5610 | 5494 |
5611 static MaybeObject* Runtime_StringTrim(RUNTIME_CALLING_CONVENTION) { | 5495 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { |
5612 RUNTIME_GET_ISOLATE; | |
5613 NoHandleAllocation ha; | 5496 NoHandleAllocation ha; |
5614 ASSERT(args.length() == 3); | 5497 ASSERT(args.length() == 3); |
5615 | 5498 |
5616 CONVERT_CHECKED(String, s, args[0]); | 5499 CONVERT_CHECKED(String, s, args[0]); |
5617 CONVERT_BOOLEAN_CHECKED(trimLeft, args[1]); | 5500 CONVERT_BOOLEAN_CHECKED(trimLeft, args[1]); |
5618 CONVERT_BOOLEAN_CHECKED(trimRight, args[2]); | 5501 CONVERT_BOOLEAN_CHECKED(trimRight, args[2]); |
5619 | 5502 |
5620 s->TryFlatten(); | 5503 s->TryFlatten(); |
5621 int length = s->length(); | 5504 int length = s->length(); |
5622 | 5505 |
(...skipping 29 matching lines...) Expand all Loading... |
5652 while (limit > 0) { | 5535 while (limit > 0) { |
5653 index = search.Search(subject, index); | 5536 index = search.Search(subject, index); |
5654 if (index < 0) return; | 5537 if (index < 0) return; |
5655 indices->Add(index); | 5538 indices->Add(index); |
5656 index += pattern_length; | 5539 index += pattern_length; |
5657 limit--; | 5540 limit--; |
5658 } | 5541 } |
5659 } | 5542 } |
5660 | 5543 |
5661 | 5544 |
5662 static MaybeObject* Runtime_StringSplit(RUNTIME_CALLING_CONVENTION) { | 5545 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { |
5663 RUNTIME_GET_ISOLATE; | |
5664 ASSERT(args.length() == 3); | 5546 ASSERT(args.length() == 3); |
5665 HandleScope handle_scope(isolate); | 5547 HandleScope handle_scope(isolate); |
5666 CONVERT_ARG_CHECKED(String, subject, 0); | 5548 CONVERT_ARG_CHECKED(String, subject, 0); |
5667 CONVERT_ARG_CHECKED(String, pattern, 1); | 5549 CONVERT_ARG_CHECKED(String, pattern, 1); |
5668 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 5550 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
5669 | 5551 |
5670 int subject_length = subject->length(); | 5552 int subject_length = subject->length(); |
5671 int pattern_length = pattern->length(); | 5553 int pattern_length = pattern->length(); |
5672 RUNTIME_ASSERT(pattern_length > 0); | 5554 RUNTIME_ASSERT(pattern_length > 0); |
5673 | 5555 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5784 ASSERT(element == Smi::FromInt(0) || | 5666 ASSERT(element == Smi::FromInt(0) || |
5785 (element->IsString() && String::cast(element)->LooksValid())); | 5667 (element->IsString() && String::cast(element)->LooksValid())); |
5786 } | 5668 } |
5787 #endif | 5669 #endif |
5788 return i; | 5670 return i; |
5789 } | 5671 } |
5790 | 5672 |
5791 | 5673 |
5792 // Converts a String to JSArray. | 5674 // Converts a String to JSArray. |
5793 // For example, "foo" => ["f", "o", "o"]. | 5675 // For example, "foo" => ["f", "o", "o"]. |
5794 static MaybeObject* Runtime_StringToArray(RUNTIME_CALLING_CONVENTION) { | 5676 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) { |
5795 RUNTIME_GET_ISOLATE; | |
5796 HandleScope scope(isolate); | 5677 HandleScope scope(isolate); |
5797 ASSERT(args.length() == 2); | 5678 ASSERT(args.length() == 2); |
5798 CONVERT_ARG_CHECKED(String, s, 0); | 5679 CONVERT_ARG_CHECKED(String, s, 0); |
5799 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 5680 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
5800 | 5681 |
5801 s->TryFlatten(); | 5682 s->TryFlatten(); |
5802 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); | 5683 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); |
5803 | 5684 |
5804 Handle<FixedArray> elements; | 5685 Handle<FixedArray> elements; |
5805 if (s->IsFlat() && s->IsAsciiRepresentation()) { | 5686 if (s->IsFlat() && s->IsAsciiRepresentation()) { |
(...skipping 27 matching lines...) Expand all Loading... |
5833 #ifdef DEBUG | 5714 #ifdef DEBUG |
5834 for (int i = 0; i < length; ++i) { | 5715 for (int i = 0; i < length; ++i) { |
5835 ASSERT(String::cast(elements->get(i))->length() == 1); | 5716 ASSERT(String::cast(elements->get(i))->length() == 1); |
5836 } | 5717 } |
5837 #endif | 5718 #endif |
5838 | 5719 |
5839 return *isolate->factory()->NewJSArrayWithElements(elements); | 5720 return *isolate->factory()->NewJSArrayWithElements(elements); |
5840 } | 5721 } |
5841 | 5722 |
5842 | 5723 |
5843 static MaybeObject* Runtime_NewStringWrapper(RUNTIME_CALLING_CONVENTION) { | 5724 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { |
5844 RUNTIME_GET_ISOLATE; | |
5845 NoHandleAllocation ha; | 5725 NoHandleAllocation ha; |
5846 ASSERT(args.length() == 1); | 5726 ASSERT(args.length() == 1); |
5847 CONVERT_CHECKED(String, value, args[0]); | 5727 CONVERT_CHECKED(String, value, args[0]); |
5848 return value->ToObject(); | 5728 return value->ToObject(); |
5849 } | 5729 } |
5850 | 5730 |
5851 | 5731 |
5852 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 5732 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
5853 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 5733 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
5854 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 5734 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
5855 return char_length == 0; | 5735 return char_length == 0; |
5856 } | 5736 } |
5857 | 5737 |
5858 | 5738 |
5859 static MaybeObject* Runtime_NumberToString(RUNTIME_CALLING_CONVENTION) { | 5739 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToString) { |
5860 RUNTIME_GET_ISOLATE; | |
5861 NoHandleAllocation ha; | 5740 NoHandleAllocation ha; |
5862 ASSERT(args.length() == 1); | 5741 ASSERT(args.length() == 1); |
5863 | 5742 |
5864 Object* number = args[0]; | 5743 Object* number = args[0]; |
5865 RUNTIME_ASSERT(number->IsNumber()); | 5744 RUNTIME_ASSERT(number->IsNumber()); |
5866 | 5745 |
5867 return isolate->heap()->NumberToString(number); | 5746 return isolate->heap()->NumberToString(number); |
5868 } | 5747 } |
5869 | 5748 |
5870 | 5749 |
5871 static MaybeObject* Runtime_NumberToStringSkipCache( | 5750 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToStringSkipCache) { |
5872 RUNTIME_CALLING_CONVENTION) { | |
5873 RUNTIME_GET_ISOLATE; | |
5874 NoHandleAllocation ha; | 5751 NoHandleAllocation ha; |
5875 ASSERT(args.length() == 1); | 5752 ASSERT(args.length() == 1); |
5876 | 5753 |
5877 Object* number = args[0]; | 5754 Object* number = args[0]; |
5878 RUNTIME_ASSERT(number->IsNumber()); | 5755 RUNTIME_ASSERT(number->IsNumber()); |
5879 | 5756 |
5880 return isolate->heap()->NumberToString(number, false); | 5757 return isolate->heap()->NumberToString(number, false); |
5881 } | 5758 } |
5882 | 5759 |
5883 | 5760 |
5884 static MaybeObject* Runtime_NumberToInteger(RUNTIME_CALLING_CONVENTION) { | 5761 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
5885 RUNTIME_GET_ISOLATE; | |
5886 NoHandleAllocation ha; | 5762 NoHandleAllocation ha; |
5887 ASSERT(args.length() == 1); | 5763 ASSERT(args.length() == 1); |
5888 | 5764 |
5889 CONVERT_DOUBLE_CHECKED(number, args[0]); | 5765 CONVERT_DOUBLE_CHECKED(number, args[0]); |
5890 | 5766 |
5891 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 5767 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
5892 if (number > 0 && number <= Smi::kMaxValue) { | 5768 if (number > 0 && number <= Smi::kMaxValue) { |
5893 return Smi::FromInt(static_cast<int>(number)); | 5769 return Smi::FromInt(static_cast<int>(number)); |
5894 } | 5770 } |
5895 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | 5771 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); |
5896 } | 5772 } |
5897 | 5773 |
5898 | 5774 |
5899 static MaybeObject* Runtime_NumberToIntegerMapMinusZero( | 5775 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { |
5900 RUNTIME_CALLING_CONVENTION) { | |
5901 RUNTIME_GET_ISOLATE; | |
5902 NoHandleAllocation ha; | 5776 NoHandleAllocation ha; |
5903 ASSERT(args.length() == 1); | 5777 ASSERT(args.length() == 1); |
5904 | 5778 |
5905 CONVERT_DOUBLE_CHECKED(number, args[0]); | 5779 CONVERT_DOUBLE_CHECKED(number, args[0]); |
5906 | 5780 |
5907 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 5781 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
5908 if (number > 0 && number <= Smi::kMaxValue) { | 5782 if (number > 0 && number <= Smi::kMaxValue) { |
5909 return Smi::FromInt(static_cast<int>(number)); | 5783 return Smi::FromInt(static_cast<int>(number)); |
5910 } | 5784 } |
5911 | 5785 |
5912 double double_value = DoubleToInteger(number); | 5786 double double_value = DoubleToInteger(number); |
5913 // Map both -0 and +0 to +0. | 5787 // Map both -0 and +0 to +0. |
5914 if (double_value == 0) double_value = 0; | 5788 if (double_value == 0) double_value = 0; |
5915 | 5789 |
5916 return isolate->heap()->NumberFromDouble(double_value); | 5790 return isolate->heap()->NumberFromDouble(double_value); |
5917 } | 5791 } |
5918 | 5792 |
5919 | 5793 |
5920 static MaybeObject* Runtime_NumberToJSUint32(RUNTIME_CALLING_CONVENTION) { | 5794 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { |
5921 RUNTIME_GET_ISOLATE; | |
5922 NoHandleAllocation ha; | 5795 NoHandleAllocation ha; |
5923 ASSERT(args.length() == 1); | 5796 ASSERT(args.length() == 1); |
5924 | 5797 |
5925 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 5798 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
5926 return isolate->heap()->NumberFromUint32(number); | 5799 return isolate->heap()->NumberFromUint32(number); |
5927 } | 5800 } |
5928 | 5801 |
5929 | 5802 |
5930 static MaybeObject* Runtime_NumberToJSInt32(RUNTIME_CALLING_CONVENTION) { | 5803 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { |
5931 RUNTIME_GET_ISOLATE; | |
5932 NoHandleAllocation ha; | 5804 NoHandleAllocation ha; |
5933 ASSERT(args.length() == 1); | 5805 ASSERT(args.length() == 1); |
5934 | 5806 |
5935 CONVERT_DOUBLE_CHECKED(number, args[0]); | 5807 CONVERT_DOUBLE_CHECKED(number, args[0]); |
5936 | 5808 |
5937 // We do not include 0 so that we don't have to treat +0 / -0 cases. | 5809 // We do not include 0 so that we don't have to treat +0 / -0 cases. |
5938 if (number > 0 && number <= Smi::kMaxValue) { | 5810 if (number > 0 && number <= Smi::kMaxValue) { |
5939 return Smi::FromInt(static_cast<int>(number)); | 5811 return Smi::FromInt(static_cast<int>(number)); |
5940 } | 5812 } |
5941 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); | 5813 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); |
5942 } | 5814 } |
5943 | 5815 |
5944 | 5816 |
5945 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 5817 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
5946 // a small integer. | 5818 // a small integer. |
5947 static MaybeObject* Runtime_NumberToSmi(RUNTIME_CALLING_CONVENTION) { | 5819 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToSmi) { |
5948 RUNTIME_GET_ISOLATE; | |
5949 NoHandleAllocation ha; | 5820 NoHandleAllocation ha; |
5950 ASSERT(args.length() == 1); | 5821 ASSERT(args.length() == 1); |
5951 | 5822 |
5952 Object* obj = args[0]; | 5823 Object* obj = args[0]; |
5953 if (obj->IsSmi()) { | 5824 if (obj->IsSmi()) { |
5954 return obj; | 5825 return obj; |
5955 } | 5826 } |
5956 if (obj->IsHeapNumber()) { | 5827 if (obj->IsHeapNumber()) { |
5957 double value = HeapNumber::cast(obj)->value(); | 5828 double value = HeapNumber::cast(obj)->value(); |
5958 int int_value = FastD2I(value); | 5829 int int_value = FastD2I(value); |
5959 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 5830 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
5960 return Smi::FromInt(int_value); | 5831 return Smi::FromInt(int_value); |
5961 } | 5832 } |
5962 } | 5833 } |
5963 return isolate->heap()->nan_value(); | 5834 return isolate->heap()->nan_value(); |
5964 } | 5835 } |
5965 | 5836 |
5966 | 5837 |
5967 static MaybeObject* Runtime_AllocateHeapNumber(RUNTIME_CALLING_CONVENTION) { | 5838 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateHeapNumber) { |
5968 RUNTIME_GET_ISOLATE; | |
5969 NoHandleAllocation ha; | 5839 NoHandleAllocation ha; |
5970 ASSERT(args.length() == 0); | 5840 ASSERT(args.length() == 0); |
5971 return isolate->heap()->AllocateHeapNumber(0); | 5841 return isolate->heap()->AllocateHeapNumber(0); |
5972 } | 5842 } |
5973 | 5843 |
5974 | 5844 |
5975 static MaybeObject* Runtime_NumberAdd(RUNTIME_CALLING_CONVENTION) { | 5845 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
5976 RUNTIME_GET_ISOLATE; | |
5977 NoHandleAllocation ha; | 5846 NoHandleAllocation ha; |
5978 ASSERT(args.length() == 2); | 5847 ASSERT(args.length() == 2); |
5979 | 5848 |
5980 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5849 CONVERT_DOUBLE_CHECKED(x, args[0]); |
5981 CONVERT_DOUBLE_CHECKED(y, args[1]); | 5850 CONVERT_DOUBLE_CHECKED(y, args[1]); |
5982 return isolate->heap()->NumberFromDouble(x + y); | 5851 return isolate->heap()->NumberFromDouble(x + y); |
5983 } | 5852 } |
5984 | 5853 |
5985 | 5854 |
5986 static MaybeObject* Runtime_NumberSub(RUNTIME_CALLING_CONVENTION) { | 5855 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { |
5987 RUNTIME_GET_ISOLATE; | |
5988 NoHandleAllocation ha; | 5856 NoHandleAllocation ha; |
5989 ASSERT(args.length() == 2); | 5857 ASSERT(args.length() == 2); |
5990 | 5858 |
5991 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5859 CONVERT_DOUBLE_CHECKED(x, args[0]); |
5992 CONVERT_DOUBLE_CHECKED(y, args[1]); | 5860 CONVERT_DOUBLE_CHECKED(y, args[1]); |
5993 return isolate->heap()->NumberFromDouble(x - y); | 5861 return isolate->heap()->NumberFromDouble(x - y); |
5994 } | 5862 } |
5995 | 5863 |
5996 | 5864 |
5997 static MaybeObject* Runtime_NumberMul(RUNTIME_CALLING_CONVENTION) { | 5865 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { |
5998 RUNTIME_GET_ISOLATE; | |
5999 NoHandleAllocation ha; | 5866 NoHandleAllocation ha; |
6000 ASSERT(args.length() == 2); | 5867 ASSERT(args.length() == 2); |
6001 | 5868 |
6002 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5869 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6003 CONVERT_DOUBLE_CHECKED(y, args[1]); | 5870 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6004 return isolate->heap()->NumberFromDouble(x * y); | 5871 return isolate->heap()->NumberFromDouble(x * y); |
6005 } | 5872 } |
6006 | 5873 |
6007 | 5874 |
6008 static MaybeObject* Runtime_NumberUnaryMinus(RUNTIME_CALLING_CONVENTION) { | 5875 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { |
6009 RUNTIME_GET_ISOLATE; | |
6010 NoHandleAllocation ha; | 5876 NoHandleAllocation ha; |
6011 ASSERT(args.length() == 1); | 5877 ASSERT(args.length() == 1); |
6012 | 5878 |
6013 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5879 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6014 return isolate->heap()->NumberFromDouble(-x); | 5880 return isolate->heap()->NumberFromDouble(-x); |
6015 } | 5881 } |
6016 | 5882 |
6017 | 5883 |
6018 static MaybeObject* Runtime_NumberAlloc(RUNTIME_CALLING_CONVENTION) { | 5884 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { |
6019 RUNTIME_GET_ISOLATE; | |
6020 NoHandleAllocation ha; | 5885 NoHandleAllocation ha; |
6021 ASSERT(args.length() == 0); | 5886 ASSERT(args.length() == 0); |
6022 | 5887 |
6023 return isolate->heap()->NumberFromDouble(9876543210.0); | 5888 return isolate->heap()->NumberFromDouble(9876543210.0); |
6024 } | 5889 } |
6025 | 5890 |
6026 | 5891 |
6027 static MaybeObject* Runtime_NumberDiv(RUNTIME_CALLING_CONVENTION) { | 5892 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { |
6028 RUNTIME_GET_ISOLATE; | |
6029 NoHandleAllocation ha; | 5893 NoHandleAllocation ha; |
6030 ASSERT(args.length() == 2); | 5894 ASSERT(args.length() == 2); |
6031 | 5895 |
6032 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5896 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6033 CONVERT_DOUBLE_CHECKED(y, args[1]); | 5897 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6034 return isolate->heap()->NumberFromDouble(x / y); | 5898 return isolate->heap()->NumberFromDouble(x / y); |
6035 } | 5899 } |
6036 | 5900 |
6037 | 5901 |
6038 static MaybeObject* Runtime_NumberMod(RUNTIME_CALLING_CONVENTION) { | 5902 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { |
6039 RUNTIME_GET_ISOLATE; | |
6040 NoHandleAllocation ha; | 5903 NoHandleAllocation ha; |
6041 ASSERT(args.length() == 2); | 5904 ASSERT(args.length() == 2); |
6042 | 5905 |
6043 CONVERT_DOUBLE_CHECKED(x, args[0]); | 5906 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6044 CONVERT_DOUBLE_CHECKED(y, args[1]); | 5907 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6045 | 5908 |
6046 x = modulo(x, y); | 5909 x = modulo(x, y); |
6047 // NumberFromDouble may return a Smi instead of a Number object | 5910 // NumberFromDouble may return a Smi instead of a Number object |
6048 return isolate->heap()->NumberFromDouble(x); | 5911 return isolate->heap()->NumberFromDouble(x); |
6049 } | 5912 } |
6050 | 5913 |
6051 | 5914 |
6052 static MaybeObject* Runtime_StringAdd(RUNTIME_CALLING_CONVENTION) { | 5915 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) { |
6053 RUNTIME_GET_ISOLATE; | |
6054 NoHandleAllocation ha; | 5916 NoHandleAllocation ha; |
6055 ASSERT(args.length() == 2); | 5917 ASSERT(args.length() == 2); |
6056 CONVERT_CHECKED(String, str1, args[0]); | 5918 CONVERT_CHECKED(String, str1, args[0]); |
6057 CONVERT_CHECKED(String, str2, args[1]); | 5919 CONVERT_CHECKED(String, str2, args[1]); |
6058 isolate->counters()->string_add_runtime()->Increment(); | 5920 isolate->counters()->string_add_runtime()->Increment(); |
6059 return isolate->heap()->AllocateConsString(str1, str2); | 5921 return isolate->heap()->AllocateConsString(str1, str2); |
6060 } | 5922 } |
6061 | 5923 |
6062 | 5924 |
6063 template <typename sinkchar> | 5925 template <typename sinkchar> |
(...skipping 28 matching lines...) Expand all Loading... |
6092 } else { | 5954 } else { |
6093 String* string = String::cast(element); | 5955 String* string = String::cast(element); |
6094 int element_length = string->length(); | 5956 int element_length = string->length(); |
6095 String::WriteToFlat(string, sink + position, 0, element_length); | 5957 String::WriteToFlat(string, sink + position, 0, element_length); |
6096 position += element_length; | 5958 position += element_length; |
6097 } | 5959 } |
6098 } | 5960 } |
6099 } | 5961 } |
6100 | 5962 |
6101 | 5963 |
6102 static MaybeObject* Runtime_StringBuilderConcat(RUNTIME_CALLING_CONVENTION) { | 5964 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { |
6103 RUNTIME_GET_ISOLATE; | |
6104 NoHandleAllocation ha; | 5965 NoHandleAllocation ha; |
6105 ASSERT(args.length() == 3); | 5966 ASSERT(args.length() == 3); |
6106 CONVERT_CHECKED(JSArray, array, args[0]); | 5967 CONVERT_CHECKED(JSArray, array, args[0]); |
6107 if (!args[1]->IsSmi()) { | 5968 if (!args[1]->IsSmi()) { |
6108 isolate->context()->mark_out_of_memory(); | 5969 isolate->context()->mark_out_of_memory(); |
6109 return Failure::OutOfMemoryException(); | 5970 return Failure::OutOfMemoryException(); |
6110 } | 5971 } |
6111 int array_length = Smi::cast(args[1])->value(); | 5972 int array_length = Smi::cast(args[1])->value(); |
6112 CONVERT_CHECKED(String, special, args[2]); | 5973 CONVERT_CHECKED(String, special, args[2]); |
6113 | 5974 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6206 SeqTwoByteString* answer = SeqTwoByteString::cast(object); | 6067 SeqTwoByteString* answer = SeqTwoByteString::cast(object); |
6207 StringBuilderConcatHelper(special, | 6068 StringBuilderConcatHelper(special, |
6208 answer->GetChars(), | 6069 answer->GetChars(), |
6209 fixed_array, | 6070 fixed_array, |
6210 array_length); | 6071 array_length); |
6211 return answer; | 6072 return answer; |
6212 } | 6073 } |
6213 } | 6074 } |
6214 | 6075 |
6215 | 6076 |
6216 static MaybeObject* Runtime_StringBuilderJoin(RUNTIME_CALLING_CONVENTION) { | 6077 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { |
6217 RUNTIME_GET_ISOLATE; | |
6218 NoHandleAllocation ha; | 6078 NoHandleAllocation ha; |
6219 ASSERT(args.length() == 3); | 6079 ASSERT(args.length() == 3); |
6220 CONVERT_CHECKED(JSArray, array, args[0]); | 6080 CONVERT_CHECKED(JSArray, array, args[0]); |
6221 if (!args[1]->IsSmi()) { | 6081 if (!args[1]->IsSmi()) { |
6222 isolate->context()->mark_out_of_memory(); | 6082 isolate->context()->mark_out_of_memory(); |
6223 return Failure::OutOfMemoryException(); | 6083 return Failure::OutOfMemoryException(); |
6224 } | 6084 } |
6225 int array_length = Smi::cast(args[1])->value(); | 6085 int array_length = Smi::cast(args[1])->value(); |
6226 CONVERT_CHECKED(String, separator, args[2]); | 6086 CONVERT_CHECKED(String, separator, args[2]); |
6227 | 6087 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6291 String::WriteToFlat(element, sink, 0, element_length); | 6151 String::WriteToFlat(element, sink, 0, element_length); |
6292 sink += element_length; | 6152 sink += element_length; |
6293 } | 6153 } |
6294 ASSERT(sink == end); | 6154 ASSERT(sink == end); |
6295 | 6155 |
6296 ASSERT(!answer->HasOnlyAsciiChars()); // Use %_FastAsciiArrayJoin instead. | 6156 ASSERT(!answer->HasOnlyAsciiChars()); // Use %_FastAsciiArrayJoin instead. |
6297 return answer; | 6157 return answer; |
6298 } | 6158 } |
6299 | 6159 |
6300 | 6160 |
6301 static MaybeObject* Runtime_NumberOr(RUNTIME_CALLING_CONVENTION) { | 6161 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { |
6302 RUNTIME_GET_ISOLATE; | |
6303 NoHandleAllocation ha; | 6162 NoHandleAllocation ha; |
6304 ASSERT(args.length() == 2); | 6163 ASSERT(args.length() == 2); |
6305 | 6164 |
6306 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6165 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6307 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6166 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6308 return isolate->heap()->NumberFromInt32(x | y); | 6167 return isolate->heap()->NumberFromInt32(x | y); |
6309 } | 6168 } |
6310 | 6169 |
6311 | 6170 |
6312 static MaybeObject* Runtime_NumberAnd(RUNTIME_CALLING_CONVENTION) { | 6171 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { |
6313 RUNTIME_GET_ISOLATE; | |
6314 NoHandleAllocation ha; | 6172 NoHandleAllocation ha; |
6315 ASSERT(args.length() == 2); | 6173 ASSERT(args.length() == 2); |
6316 | 6174 |
6317 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6175 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6318 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6176 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6319 return isolate->heap()->NumberFromInt32(x & y); | 6177 return isolate->heap()->NumberFromInt32(x & y); |
6320 } | 6178 } |
6321 | 6179 |
6322 | 6180 |
6323 static MaybeObject* Runtime_NumberXor(RUNTIME_CALLING_CONVENTION) { | 6181 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { |
6324 RUNTIME_GET_ISOLATE; | |
6325 NoHandleAllocation ha; | 6182 NoHandleAllocation ha; |
6326 ASSERT(args.length() == 2); | 6183 ASSERT(args.length() == 2); |
6327 | 6184 |
6328 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6185 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6329 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6186 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6330 return isolate->heap()->NumberFromInt32(x ^ y); | 6187 return isolate->heap()->NumberFromInt32(x ^ y); |
6331 } | 6188 } |
6332 | 6189 |
6333 | 6190 |
6334 static MaybeObject* Runtime_NumberNot(RUNTIME_CALLING_CONVENTION) { | 6191 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberNot) { |
6335 RUNTIME_GET_ISOLATE; | |
6336 NoHandleAllocation ha; | 6192 NoHandleAllocation ha; |
6337 ASSERT(args.length() == 1); | 6193 ASSERT(args.length() == 1); |
6338 | 6194 |
6339 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6195 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6340 return isolate->heap()->NumberFromInt32(~x); | 6196 return isolate->heap()->NumberFromInt32(~x); |
6341 } | 6197 } |
6342 | 6198 |
6343 | 6199 |
6344 static MaybeObject* Runtime_NumberShl(RUNTIME_CALLING_CONVENTION) { | 6200 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { |
6345 RUNTIME_GET_ISOLATE; | |
6346 NoHandleAllocation ha; | 6201 NoHandleAllocation ha; |
6347 ASSERT(args.length() == 2); | 6202 ASSERT(args.length() == 2); |
6348 | 6203 |
6349 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6204 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6350 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6205 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6351 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); | 6206 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); |
6352 } | 6207 } |
6353 | 6208 |
6354 | 6209 |
6355 static MaybeObject* Runtime_NumberShr(RUNTIME_CALLING_CONVENTION) { | 6210 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { |
6356 RUNTIME_GET_ISOLATE; | |
6357 NoHandleAllocation ha; | 6211 NoHandleAllocation ha; |
6358 ASSERT(args.length() == 2); | 6212 ASSERT(args.length() == 2); |
6359 | 6213 |
6360 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 6214 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
6361 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6215 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6362 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); | 6216 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); |
6363 } | 6217 } |
6364 | 6218 |
6365 | 6219 |
6366 static MaybeObject* Runtime_NumberSar(RUNTIME_CALLING_CONVENTION) { | 6220 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { |
6367 RUNTIME_GET_ISOLATE; | |
6368 NoHandleAllocation ha; | 6221 NoHandleAllocation ha; |
6369 ASSERT(args.length() == 2); | 6222 ASSERT(args.length() == 2); |
6370 | 6223 |
6371 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 6224 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
6372 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 6225 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
6373 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); | 6226 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); |
6374 } | 6227 } |
6375 | 6228 |
6376 | 6229 |
6377 static MaybeObject* Runtime_NumberEquals(RUNTIME_CALLING_CONVENTION) { | 6230 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { |
6378 RUNTIME_GET_ISOLATE; | |
6379 NoHandleAllocation ha; | 6231 NoHandleAllocation ha; |
6380 ASSERT(args.length() == 2); | 6232 ASSERT(args.length() == 2); |
6381 | 6233 |
6382 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6234 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6383 CONVERT_DOUBLE_CHECKED(y, args[1]); | 6235 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6384 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); | 6236 if (isnan(x)) return Smi::FromInt(NOT_EQUAL); |
6385 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); | 6237 if (isnan(y)) return Smi::FromInt(NOT_EQUAL); |
6386 if (x == y) return Smi::FromInt(EQUAL); | 6238 if (x == y) return Smi::FromInt(EQUAL); |
6387 Object* result; | 6239 Object* result; |
6388 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 6240 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
6389 result = Smi::FromInt(EQUAL); | 6241 result = Smi::FromInt(EQUAL); |
6390 } else { | 6242 } else { |
6391 result = Smi::FromInt(NOT_EQUAL); | 6243 result = Smi::FromInt(NOT_EQUAL); |
6392 } | 6244 } |
6393 return result; | 6245 return result; |
6394 } | 6246 } |
6395 | 6247 |
6396 | 6248 |
6397 static MaybeObject* Runtime_StringEquals(RUNTIME_CALLING_CONVENTION) { | 6249 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { |
6398 RUNTIME_GET_ISOLATE; | |
6399 NoHandleAllocation ha; | 6250 NoHandleAllocation ha; |
6400 ASSERT(args.length() == 2); | 6251 ASSERT(args.length() == 2); |
6401 | 6252 |
6402 CONVERT_CHECKED(String, x, args[0]); | 6253 CONVERT_CHECKED(String, x, args[0]); |
6403 CONVERT_CHECKED(String, y, args[1]); | 6254 CONVERT_CHECKED(String, y, args[1]); |
6404 | 6255 |
6405 bool not_equal = !x->Equals(y); | 6256 bool not_equal = !x->Equals(y); |
6406 // This is slightly convoluted because the value that signifies | 6257 // This is slightly convoluted because the value that signifies |
6407 // equality is 0 and inequality is 1 so we have to negate the result | 6258 // equality is 0 and inequality is 1 so we have to negate the result |
6408 // from String::Equals. | 6259 // from String::Equals. |
6409 ASSERT(not_equal == 0 || not_equal == 1); | 6260 ASSERT(not_equal == 0 || not_equal == 1); |
6410 STATIC_CHECK(EQUAL == 0); | 6261 STATIC_CHECK(EQUAL == 0); |
6411 STATIC_CHECK(NOT_EQUAL == 1); | 6262 STATIC_CHECK(NOT_EQUAL == 1); |
6412 return Smi::FromInt(not_equal); | 6263 return Smi::FromInt(not_equal); |
6413 } | 6264 } |
6414 | 6265 |
6415 | 6266 |
6416 static MaybeObject* Runtime_NumberCompare(RUNTIME_CALLING_CONVENTION) { | 6267 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { |
6417 RUNTIME_GET_ISOLATE; | |
6418 NoHandleAllocation ha; | 6268 NoHandleAllocation ha; |
6419 ASSERT(args.length() == 3); | 6269 ASSERT(args.length() == 3); |
6420 | 6270 |
6421 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6271 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6422 CONVERT_DOUBLE_CHECKED(y, args[1]); | 6272 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6423 if (isnan(x) || isnan(y)) return args[2]; | 6273 if (isnan(x) || isnan(y)) return args[2]; |
6424 if (x == y) return Smi::FromInt(EQUAL); | 6274 if (x == y) return Smi::FromInt(EQUAL); |
6425 if (isless(x, y)) return Smi::FromInt(LESS); | 6275 if (isless(x, y)) return Smi::FromInt(LESS); |
6426 return Smi::FromInt(GREATER); | 6276 return Smi::FromInt(GREATER); |
6427 } | 6277 } |
6428 | 6278 |
6429 | 6279 |
6430 // Compare two Smis as if they were converted to strings and then | 6280 // Compare two Smis as if they were converted to strings and then |
6431 // compared lexicographically. | 6281 // compared lexicographically. |
6432 static MaybeObject* Runtime_SmiLexicographicCompare( | 6282 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { |
6433 RUNTIME_CALLING_CONVENTION) { | |
6434 RUNTIME_GET_ISOLATE; | |
6435 NoHandleAllocation ha; | 6283 NoHandleAllocation ha; |
6436 ASSERT(args.length() == 2); | 6284 ASSERT(args.length() == 2); |
6437 | 6285 |
6438 // Extract the integer values from the Smis. | 6286 // Extract the integer values from the Smis. |
6439 CONVERT_CHECKED(Smi, x, args[0]); | 6287 CONVERT_CHECKED(Smi, x, args[0]); |
6440 CONVERT_CHECKED(Smi, y, args[1]); | 6288 CONVERT_CHECKED(Smi, y, args[1]); |
6441 int x_value = x->value(); | 6289 int x_value = x->value(); |
6442 int y_value = y->value(); | 6290 int y_value = y->value(); |
6443 | 6291 |
6444 // If the integers are equal so are the string representations. | 6292 // If the integers are equal so are the string representations. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6547 result = equal_prefix_result; | 6395 result = equal_prefix_result; |
6548 } else { | 6396 } else { |
6549 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 6397 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
6550 } | 6398 } |
6551 ASSERT(result == | 6399 ASSERT(result == |
6552 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y)); | 6400 StringInputBufferCompare(Isolate::Current()->runtime_state(), x, y)); |
6553 return result; | 6401 return result; |
6554 } | 6402 } |
6555 | 6403 |
6556 | 6404 |
6557 static MaybeObject* Runtime_StringCompare(RUNTIME_CALLING_CONVENTION) { | 6405 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCompare) { |
6558 RUNTIME_GET_ISOLATE; | |
6559 NoHandleAllocation ha; | 6406 NoHandleAllocation ha; |
6560 ASSERT(args.length() == 2); | 6407 ASSERT(args.length() == 2); |
6561 | 6408 |
6562 CONVERT_CHECKED(String, x, args[0]); | 6409 CONVERT_CHECKED(String, x, args[0]); |
6563 CONVERT_CHECKED(String, y, args[1]); | 6410 CONVERT_CHECKED(String, y, args[1]); |
6564 | 6411 |
6565 isolate->counters()->string_compare_runtime()->Increment(); | 6412 isolate->counters()->string_compare_runtime()->Increment(); |
6566 | 6413 |
6567 // A few fast case tests before we flatten. | 6414 // A few fast case tests before we flatten. |
6568 if (x == y) return Smi::FromInt(EQUAL); | 6415 if (x == y) return Smi::FromInt(EQUAL); |
(...skipping 14 matching lines...) Expand all Loading... |
6583 } | 6430 } |
6584 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); | 6431 { MaybeObject* maybe_obj = isolate->heap()->PrepareForCompare(y); |
6585 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 6432 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
6586 } | 6433 } |
6587 | 6434 |
6588 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) | 6435 return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y) |
6589 : StringInputBufferCompare(isolate->runtime_state(), x, y); | 6436 : StringInputBufferCompare(isolate->runtime_state(), x, y); |
6590 } | 6437 } |
6591 | 6438 |
6592 | 6439 |
6593 static MaybeObject* Runtime_Math_acos(RUNTIME_CALLING_CONVENTION) { | 6440 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { |
6594 RUNTIME_GET_ISOLATE; | |
6595 NoHandleAllocation ha; | 6441 NoHandleAllocation ha; |
6596 ASSERT(args.length() == 1); | 6442 ASSERT(args.length() == 1); |
6597 isolate->counters()->math_acos()->Increment(); | 6443 isolate->counters()->math_acos()->Increment(); |
6598 | 6444 |
6599 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6445 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6600 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); | 6446 return isolate->transcendental_cache()->Get(TranscendentalCache::ACOS, x); |
6601 } | 6447 } |
6602 | 6448 |
6603 | 6449 |
6604 static MaybeObject* Runtime_Math_asin(RUNTIME_CALLING_CONVENTION) { | 6450 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { |
6605 RUNTIME_GET_ISOLATE; | |
6606 NoHandleAllocation ha; | 6451 NoHandleAllocation ha; |
6607 ASSERT(args.length() == 1); | 6452 ASSERT(args.length() == 1); |
6608 isolate->counters()->math_asin()->Increment(); | 6453 isolate->counters()->math_asin()->Increment(); |
6609 | 6454 |
6610 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6455 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6611 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); | 6456 return isolate->transcendental_cache()->Get(TranscendentalCache::ASIN, x); |
6612 } | 6457 } |
6613 | 6458 |
6614 | 6459 |
6615 static MaybeObject* Runtime_Math_atan(RUNTIME_CALLING_CONVENTION) { | 6460 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { |
6616 RUNTIME_GET_ISOLATE; | |
6617 NoHandleAllocation ha; | 6461 NoHandleAllocation ha; |
6618 ASSERT(args.length() == 1); | 6462 ASSERT(args.length() == 1); |
6619 isolate->counters()->math_atan()->Increment(); | 6463 isolate->counters()->math_atan()->Increment(); |
6620 | 6464 |
6621 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6465 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6622 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); | 6466 return isolate->transcendental_cache()->Get(TranscendentalCache::ATAN, x); |
6623 } | 6467 } |
6624 | 6468 |
6625 | 6469 |
6626 static const double kPiDividedBy4 = 0.78539816339744830962; | 6470 static const double kPiDividedBy4 = 0.78539816339744830962; |
6627 | 6471 |
6628 | 6472 |
6629 static MaybeObject* Runtime_Math_atan2(RUNTIME_CALLING_CONVENTION) { | 6473 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { |
6630 RUNTIME_GET_ISOLATE; | |
6631 NoHandleAllocation ha; | 6474 NoHandleAllocation ha; |
6632 ASSERT(args.length() == 2); | 6475 ASSERT(args.length() == 2); |
6633 isolate->counters()->math_atan2()->Increment(); | 6476 isolate->counters()->math_atan2()->Increment(); |
6634 | 6477 |
6635 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6478 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6636 CONVERT_DOUBLE_CHECKED(y, args[1]); | 6479 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6637 double result; | 6480 double result; |
6638 if (isinf(x) && isinf(y)) { | 6481 if (isinf(x) && isinf(y)) { |
6639 // Make sure that the result in case of two infinite arguments | 6482 // Make sure that the result in case of two infinite arguments |
6640 // is a multiple of Pi / 4. The sign of the result is determined | 6483 // is a multiple of Pi / 4. The sign of the result is determined |
6641 // by the first argument (x) and the sign of the second argument | 6484 // by the first argument (x) and the sign of the second argument |
6642 // determines the multiplier: one or three. | 6485 // determines the multiplier: one or three. |
6643 int multiplier = (x < 0) ? -1 : 1; | 6486 int multiplier = (x < 0) ? -1 : 1; |
6644 if (y < 0) multiplier *= 3; | 6487 if (y < 0) multiplier *= 3; |
6645 result = multiplier * kPiDividedBy4; | 6488 result = multiplier * kPiDividedBy4; |
6646 } else { | 6489 } else { |
6647 result = atan2(x, y); | 6490 result = atan2(x, y); |
6648 } | 6491 } |
6649 return isolate->heap()->AllocateHeapNumber(result); | 6492 return isolate->heap()->AllocateHeapNumber(result); |
6650 } | 6493 } |
6651 | 6494 |
6652 | 6495 |
6653 static MaybeObject* Runtime_Math_ceil(RUNTIME_CALLING_CONVENTION) { | 6496 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_ceil) { |
6654 RUNTIME_GET_ISOLATE; | |
6655 NoHandleAllocation ha; | 6497 NoHandleAllocation ha; |
6656 ASSERT(args.length() == 1); | 6498 ASSERT(args.length() == 1); |
6657 isolate->counters()->math_ceil()->Increment(); | 6499 isolate->counters()->math_ceil()->Increment(); |
6658 | 6500 |
6659 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6501 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6660 return isolate->heap()->NumberFromDouble(ceiling(x)); | 6502 return isolate->heap()->NumberFromDouble(ceiling(x)); |
6661 } | 6503 } |
6662 | 6504 |
6663 | 6505 |
6664 static MaybeObject* Runtime_Math_cos(RUNTIME_CALLING_CONVENTION) { | 6506 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_cos) { |
6665 RUNTIME_GET_ISOLATE; | |
6666 NoHandleAllocation ha; | 6507 NoHandleAllocation ha; |
6667 ASSERT(args.length() == 1); | 6508 ASSERT(args.length() == 1); |
6668 isolate->counters()->math_cos()->Increment(); | 6509 isolate->counters()->math_cos()->Increment(); |
6669 | 6510 |
6670 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6511 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6671 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); | 6512 return isolate->transcendental_cache()->Get(TranscendentalCache::COS, x); |
6672 } | 6513 } |
6673 | 6514 |
6674 | 6515 |
6675 static MaybeObject* Runtime_Math_exp(RUNTIME_CALLING_CONVENTION) { | 6516 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { |
6676 RUNTIME_GET_ISOLATE; | |
6677 NoHandleAllocation ha; | 6517 NoHandleAllocation ha; |
6678 ASSERT(args.length() == 1); | 6518 ASSERT(args.length() == 1); |
6679 isolate->counters()->math_exp()->Increment(); | 6519 isolate->counters()->math_exp()->Increment(); |
6680 | 6520 |
6681 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6521 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6682 return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x); | 6522 return isolate->transcendental_cache()->Get(TranscendentalCache::EXP, x); |
6683 } | 6523 } |
6684 | 6524 |
6685 | 6525 |
6686 static MaybeObject* Runtime_Math_floor(RUNTIME_CALLING_CONVENTION) { | 6526 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { |
6687 RUNTIME_GET_ISOLATE; | |
6688 NoHandleAllocation ha; | 6527 NoHandleAllocation ha; |
6689 ASSERT(args.length() == 1); | 6528 ASSERT(args.length() == 1); |
6690 isolate->counters()->math_floor()->Increment(); | 6529 isolate->counters()->math_floor()->Increment(); |
6691 | 6530 |
6692 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6531 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6693 return isolate->heap()->NumberFromDouble(floor(x)); | 6532 return isolate->heap()->NumberFromDouble(floor(x)); |
6694 } | 6533 } |
6695 | 6534 |
6696 | 6535 |
6697 static MaybeObject* Runtime_Math_log(RUNTIME_CALLING_CONVENTION) { | 6536 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { |
6698 RUNTIME_GET_ISOLATE; | |
6699 NoHandleAllocation ha; | 6537 NoHandleAllocation ha; |
6700 ASSERT(args.length() == 1); | 6538 ASSERT(args.length() == 1); |
6701 isolate->counters()->math_log()->Increment(); | 6539 isolate->counters()->math_log()->Increment(); |
6702 | 6540 |
6703 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6541 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6704 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); | 6542 return isolate->transcendental_cache()->Get(TranscendentalCache::LOG, x); |
6705 } | 6543 } |
6706 | 6544 |
6707 | 6545 |
6708 static MaybeObject* Runtime_Math_pow(RUNTIME_CALLING_CONVENTION) { | 6546 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { |
6709 RUNTIME_GET_ISOLATE; | |
6710 NoHandleAllocation ha; | 6547 NoHandleAllocation ha; |
6711 ASSERT(args.length() == 2); | 6548 ASSERT(args.length() == 2); |
6712 isolate->counters()->math_pow()->Increment(); | 6549 isolate->counters()->math_pow()->Increment(); |
6713 | 6550 |
6714 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6551 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6715 | 6552 |
6716 // If the second argument is a smi, it is much faster to call the | 6553 // If the second argument is a smi, it is much faster to call the |
6717 // custom powi() function than the generic pow(). | 6554 // custom powi() function than the generic pow(). |
6718 if (args[1]->IsSmi()) { | 6555 if (args[1]->IsSmi()) { |
6719 int y = Smi::cast(args[1])->value(); | 6556 int y = Smi::cast(args[1])->value(); |
6720 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); | 6557 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); |
6721 } | 6558 } |
6722 | 6559 |
6723 CONVERT_DOUBLE_CHECKED(y, args[1]); | 6560 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6724 return isolate->heap()->AllocateHeapNumber(power_double_double(x, y)); | 6561 return isolate->heap()->AllocateHeapNumber(power_double_double(x, y)); |
6725 } | 6562 } |
6726 | 6563 |
6727 // Fast version of Math.pow if we know that y is not an integer and | 6564 // Fast version of Math.pow if we know that y is not an integer and |
6728 // y is not -0.5 or 0.5. Used as slowcase from codegen. | 6565 // y is not -0.5 or 0.5. Used as slowcase from codegen. |
6729 static MaybeObject* Runtime_Math_pow_cfunction(RUNTIME_CALLING_CONVENTION) { | 6566 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow_cfunction) { |
6730 RUNTIME_GET_ISOLATE; | |
6731 NoHandleAllocation ha; | 6567 NoHandleAllocation ha; |
6732 ASSERT(args.length() == 2); | 6568 ASSERT(args.length() == 2); |
6733 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6569 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6734 CONVERT_DOUBLE_CHECKED(y, args[1]); | 6570 CONVERT_DOUBLE_CHECKED(y, args[1]); |
6735 if (y == 0) { | 6571 if (y == 0) { |
6736 return Smi::FromInt(1); | 6572 return Smi::FromInt(1); |
6737 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { | 6573 } else if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { |
6738 return isolate->heap()->nan_value(); | 6574 return isolate->heap()->nan_value(); |
6739 } else { | 6575 } else { |
6740 return isolate->heap()->AllocateHeapNumber(pow(x, y)); | 6576 return isolate->heap()->AllocateHeapNumber(pow(x, y)); |
6741 } | 6577 } |
6742 } | 6578 } |
6743 | 6579 |
6744 | 6580 |
6745 static MaybeObject* Runtime_RoundNumber(RUNTIME_CALLING_CONVENTION) { | 6581 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { |
6746 RUNTIME_GET_ISOLATE; | |
6747 NoHandleAllocation ha; | 6582 NoHandleAllocation ha; |
6748 ASSERT(args.length() == 1); | 6583 ASSERT(args.length() == 1); |
6749 isolate->counters()->math_round()->Increment(); | 6584 isolate->counters()->math_round()->Increment(); |
6750 | 6585 |
6751 if (!args[0]->IsHeapNumber()) { | 6586 if (!args[0]->IsHeapNumber()) { |
6752 // Must be smi. Return the argument unchanged for all the other types | 6587 // Must be smi. Return the argument unchanged for all the other types |
6753 // to make fuzz-natives test happy. | 6588 // to make fuzz-natives test happy. |
6754 return args[0]; | 6589 return args[0]; |
6755 } | 6590 } |
6756 | 6591 |
(...skipping 15 matching lines...) Expand all Loading... |
6772 return number; | 6607 return number; |
6773 } | 6608 } |
6774 | 6609 |
6775 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 6610 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
6776 | 6611 |
6777 // Do not call NumberFromDouble() to avoid extra checks. | 6612 // Do not call NumberFromDouble() to avoid extra checks. |
6778 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); | 6613 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); |
6779 } | 6614 } |
6780 | 6615 |
6781 | 6616 |
6782 static MaybeObject* Runtime_Math_sin(RUNTIME_CALLING_CONVENTION) { | 6617 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sin) { |
6783 RUNTIME_GET_ISOLATE; | |
6784 NoHandleAllocation ha; | 6618 NoHandleAllocation ha; |
6785 ASSERT(args.length() == 1); | 6619 ASSERT(args.length() == 1); |
6786 isolate->counters()->math_sin()->Increment(); | 6620 isolate->counters()->math_sin()->Increment(); |
6787 | 6621 |
6788 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6622 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6789 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); | 6623 return isolate->transcendental_cache()->Get(TranscendentalCache::SIN, x); |
6790 } | 6624 } |
6791 | 6625 |
6792 | 6626 |
6793 static MaybeObject* Runtime_Math_sqrt(RUNTIME_CALLING_CONVENTION) { | 6627 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { |
6794 RUNTIME_GET_ISOLATE; | |
6795 NoHandleAllocation ha; | 6628 NoHandleAllocation ha; |
6796 ASSERT(args.length() == 1); | 6629 ASSERT(args.length() == 1); |
6797 isolate->counters()->math_sqrt()->Increment(); | 6630 isolate->counters()->math_sqrt()->Increment(); |
6798 | 6631 |
6799 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6632 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6800 return isolate->heap()->AllocateHeapNumber(sqrt(x)); | 6633 return isolate->heap()->AllocateHeapNumber(sqrt(x)); |
6801 } | 6634 } |
6802 | 6635 |
6803 | 6636 |
6804 static MaybeObject* Runtime_Math_tan(RUNTIME_CALLING_CONVENTION) { | 6637 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_tan) { |
6805 RUNTIME_GET_ISOLATE; | |
6806 NoHandleAllocation ha; | 6638 NoHandleAllocation ha; |
6807 ASSERT(args.length() == 1); | 6639 ASSERT(args.length() == 1); |
6808 isolate->counters()->math_tan()->Increment(); | 6640 isolate->counters()->math_tan()->Increment(); |
6809 | 6641 |
6810 CONVERT_DOUBLE_CHECKED(x, args[0]); | 6642 CONVERT_DOUBLE_CHECKED(x, args[0]); |
6811 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); | 6643 return isolate->transcendental_cache()->Get(TranscendentalCache::TAN, x); |
6812 } | 6644 } |
6813 | 6645 |
6814 | 6646 |
6815 static int MakeDay(int year, int month, int day) { | 6647 static int MakeDay(int year, int month, int day) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6850 base_day; | 6682 base_day; |
6851 | 6683 |
6852 if (year % 4 || (year % 100 == 0 && year % 400 != 0)) { | 6684 if (year % 4 || (year % 100 == 0 && year % 400 != 0)) { |
6853 return day_from_year + day_from_month[month] + day - 1; | 6685 return day_from_year + day_from_month[month] + day - 1; |
6854 } | 6686 } |
6855 | 6687 |
6856 return day_from_year + day_from_month_leap[month] + day - 1; | 6688 return day_from_year + day_from_month_leap[month] + day - 1; |
6857 } | 6689 } |
6858 | 6690 |
6859 | 6691 |
6860 static MaybeObject* Runtime_DateMakeDay(RUNTIME_CALLING_CONVENTION) { | 6692 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
6861 RUNTIME_GET_ISOLATE; | |
6862 NoHandleAllocation ha; | 6693 NoHandleAllocation ha; |
6863 ASSERT(args.length() == 3); | 6694 ASSERT(args.length() == 3); |
6864 | 6695 |
6865 CONVERT_SMI_CHECKED(year, args[0]); | 6696 CONVERT_SMI_CHECKED(year, args[0]); |
6866 CONVERT_SMI_CHECKED(month, args[1]); | 6697 CONVERT_SMI_CHECKED(month, args[1]); |
6867 CONVERT_SMI_CHECKED(date, args[2]); | 6698 CONVERT_SMI_CHECKED(date, args[2]); |
6868 | 6699 |
6869 return Smi::FromInt(MakeDay(year, month, date)); | 6700 return Smi::FromInt(MakeDay(year, month, date)); |
6870 } | 6701 } |
6871 | 6702 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7150 static inline void DateYMDFromTime(int date, | 6981 static inline void DateYMDFromTime(int date, |
7151 int& year, int& month, int& day) { | 6982 int& year, int& month, int& day) { |
7152 if (date >= 0 && date < 32 * kDaysIn4Years) { | 6983 if (date >= 0 && date < 32 * kDaysIn4Years) { |
7153 DateYMDFromTimeAfter1970(date, year, month, day); | 6984 DateYMDFromTimeAfter1970(date, year, month, day); |
7154 } else { | 6985 } else { |
7155 DateYMDFromTimeSlow(date, year, month, day); | 6986 DateYMDFromTimeSlow(date, year, month, day); |
7156 } | 6987 } |
7157 } | 6988 } |
7158 | 6989 |
7159 | 6990 |
7160 static MaybeObject* Runtime_DateYMDFromTime(RUNTIME_CALLING_CONVENTION) { | 6991 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateYMDFromTime) { |
7161 RUNTIME_GET_ISOLATE; | |
7162 NoHandleAllocation ha; | 6992 NoHandleAllocation ha; |
7163 ASSERT(args.length() == 2); | 6993 ASSERT(args.length() == 2); |
7164 | 6994 |
7165 CONVERT_DOUBLE_CHECKED(t, args[0]); | 6995 CONVERT_DOUBLE_CHECKED(t, args[0]); |
7166 CONVERT_CHECKED(JSArray, res_array, args[1]); | 6996 CONVERT_CHECKED(JSArray, res_array, args[1]); |
7167 | 6997 |
7168 int year, month, day; | 6998 int year, month, day; |
7169 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); | 6999 DateYMDFromTime(static_cast<int>(floor(t / 86400000)), year, month, day); |
7170 | 7000 |
7171 RUNTIME_ASSERT(res_array->elements()->map() == | 7001 RUNTIME_ASSERT(res_array->elements()->map() == |
7172 isolate->heap()->fixed_array_map()); | 7002 isolate->heap()->fixed_array_map()); |
7173 FixedArray* elms = FixedArray::cast(res_array->elements()); | 7003 FixedArray* elms = FixedArray::cast(res_array->elements()); |
7174 RUNTIME_ASSERT(elms->length() == 3); | 7004 RUNTIME_ASSERT(elms->length() == 3); |
7175 | 7005 |
7176 elms->set(0, Smi::FromInt(year)); | 7006 elms->set(0, Smi::FromInt(year)); |
7177 elms->set(1, Smi::FromInt(month)); | 7007 elms->set(1, Smi::FromInt(month)); |
7178 elms->set(2, Smi::FromInt(day)); | 7008 elms->set(2, Smi::FromInt(day)); |
7179 | 7009 |
7180 return isolate->heap()->undefined_value(); | 7010 return isolate->heap()->undefined_value(); |
7181 } | 7011 } |
7182 | 7012 |
7183 | 7013 |
7184 static MaybeObject* Runtime_NewArgumentsFast(RUNTIME_CALLING_CONVENTION) { | 7014 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewArgumentsFast) { |
7185 RUNTIME_GET_ISOLATE; | |
7186 NoHandleAllocation ha; | 7015 NoHandleAllocation ha; |
7187 ASSERT(args.length() == 3); | 7016 ASSERT(args.length() == 3); |
7188 | 7017 |
7189 JSFunction* callee = JSFunction::cast(args[0]); | 7018 JSFunction* callee = JSFunction::cast(args[0]); |
7190 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7019 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7191 const int length = Smi::cast(args[2])->value(); | 7020 const int length = Smi::cast(args[2])->value(); |
7192 | 7021 |
7193 Object* result; | 7022 Object* result; |
7194 { MaybeObject* maybe_result = | 7023 { MaybeObject* maybe_result = |
7195 isolate->heap()->AllocateArgumentsObject(callee, length); | 7024 isolate->heap()->AllocateArgumentsObject(callee, length); |
(...skipping 15 matching lines...) Expand all Loading... |
7211 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 7040 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
7212 for (int i = 0; i < length; i++) { | 7041 for (int i = 0; i < length; i++) { |
7213 array->set(i, *--parameters, mode); | 7042 array->set(i, *--parameters, mode); |
7214 } | 7043 } |
7215 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 7044 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
7216 } | 7045 } |
7217 return result; | 7046 return result; |
7218 } | 7047 } |
7219 | 7048 |
7220 | 7049 |
7221 static MaybeObject* Runtime_NewClosure(RUNTIME_CALLING_CONVENTION) { | 7050 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { |
7222 RUNTIME_GET_ISOLATE; | |
7223 HandleScope scope(isolate); | 7051 HandleScope scope(isolate); |
7224 ASSERT(args.length() == 3); | 7052 ASSERT(args.length() == 3); |
7225 CONVERT_ARG_CHECKED(Context, context, 0); | 7053 CONVERT_ARG_CHECKED(Context, context, 0); |
7226 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); | 7054 CONVERT_ARG_CHECKED(SharedFunctionInfo, shared, 1); |
7227 CONVERT_BOOLEAN_CHECKED(pretenure, args[2]); | 7055 CONVERT_BOOLEAN_CHECKED(pretenure, args[2]); |
7228 | 7056 |
7229 // Allocate global closures in old space and allocate local closures | 7057 // Allocate global closures in old space and allocate local closures |
7230 // in new space. Additionally pretenure closures that are assigned | 7058 // in new space. Additionally pretenure closures that are assigned |
7231 // directly to properties. | 7059 // directly to properties. |
7232 pretenure = pretenure || (context->global_context() == *context); | 7060 pretenure = pretenure || (context->global_context() == *context); |
7233 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 7061 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
7234 Handle<JSFunction> result = | 7062 Handle<JSFunction> result = |
7235 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, | 7063 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
7236 context, | 7064 context, |
7237 pretenure_flag); | 7065 pretenure_flag); |
7238 return *result; | 7066 return *result; |
7239 } | 7067 } |
7240 | 7068 |
7241 static MaybeObject* Runtime_NewObjectFromBound(RUNTIME_CALLING_CONVENTION) { | 7069 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { |
7242 RUNTIME_GET_ISOLATE; | |
7243 HandleScope scope(isolate); | 7070 HandleScope scope(isolate); |
7244 ASSERT(args.length() == 2); | 7071 ASSERT(args.length() == 2); |
7245 // First argument is a function to use as a constructor. | 7072 // First argument is a function to use as a constructor. |
7246 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 7073 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
7247 | 7074 |
7248 // Second argument is either null or an array of bound arguments. | 7075 // Second argument is either null or an array of bound arguments. |
7249 FixedArray* bound_args = NULL; | 7076 FixedArray* bound_args = NULL; |
7250 int bound_argc = 0; | 7077 int bound_argc = 0; |
7251 if (!args[1]->IsNull()) { | 7078 if (!args[1]->IsNull()) { |
7252 CONVERT_ARG_CHECKED(JSArray, params, 1); | 7079 CONVERT_ARG_CHECKED(JSArray, params, 1); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7297 ConstructStubCompiler compiler; | 7124 ConstructStubCompiler compiler; |
7298 MaybeObject* code = compiler.CompileConstructStub(*function); | 7125 MaybeObject* code = compiler.CompileConstructStub(*function); |
7299 if (!code->IsFailure()) { | 7126 if (!code->IsFailure()) { |
7300 function->shared()->set_construct_stub( | 7127 function->shared()->set_construct_stub( |
7301 Code::cast(code->ToObjectUnchecked())); | 7128 Code::cast(code->ToObjectUnchecked())); |
7302 } | 7129 } |
7303 } | 7130 } |
7304 } | 7131 } |
7305 | 7132 |
7306 | 7133 |
7307 static MaybeObject* Runtime_NewObject(RUNTIME_CALLING_CONVENTION) { | 7134 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObject) { |
7308 RUNTIME_GET_ISOLATE; | |
7309 HandleScope scope(isolate); | 7135 HandleScope scope(isolate); |
7310 ASSERT(args.length() == 1); | 7136 ASSERT(args.length() == 1); |
7311 | 7137 |
7312 Handle<Object> constructor = args.at<Object>(0); | 7138 Handle<Object> constructor = args.at<Object>(0); |
7313 | 7139 |
7314 // If the constructor isn't a proper function we throw a type error. | 7140 // If the constructor isn't a proper function we throw a type error. |
7315 if (!constructor->IsJSFunction()) { | 7141 if (!constructor->IsJSFunction()) { |
7316 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 7142 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
7317 Handle<Object> type_error = | 7143 Handle<Object> type_error = |
7318 isolate->factory()->NewTypeError("not_constructor", arguments); | 7144 isolate->factory()->NewTypeError("not_constructor", arguments); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7378 TrySettingInlineConstructStub(isolate, function); | 7204 TrySettingInlineConstructStub(isolate, function); |
7379 } | 7205 } |
7380 | 7206 |
7381 isolate->counters()->constructed_objects()->Increment(); | 7207 isolate->counters()->constructed_objects()->Increment(); |
7382 isolate->counters()->constructed_objects_runtime()->Increment(); | 7208 isolate->counters()->constructed_objects_runtime()->Increment(); |
7383 | 7209 |
7384 return *result; | 7210 return *result; |
7385 } | 7211 } |
7386 | 7212 |
7387 | 7213 |
7388 static MaybeObject* Runtime_FinalizeInstanceSize(RUNTIME_CALLING_CONVENTION) { | 7214 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinalizeInstanceSize) { |
7389 RUNTIME_GET_ISOLATE; | |
7390 HandleScope scope(isolate); | 7215 HandleScope scope(isolate); |
7391 ASSERT(args.length() == 1); | 7216 ASSERT(args.length() == 1); |
7392 | 7217 |
7393 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 7218 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
7394 function->shared()->CompleteInobjectSlackTracking(); | 7219 function->shared()->CompleteInobjectSlackTracking(); |
7395 TrySettingInlineConstructStub(isolate, function); | 7220 TrySettingInlineConstructStub(isolate, function); |
7396 | 7221 |
7397 return isolate->heap()->undefined_value(); | 7222 return isolate->heap()->undefined_value(); |
7398 } | 7223 } |
7399 | 7224 |
7400 | 7225 |
7401 static MaybeObject* Runtime_LazyCompile(RUNTIME_CALLING_CONVENTION) { | 7226 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyCompile) { |
7402 RUNTIME_GET_ISOLATE; | |
7403 HandleScope scope(isolate); | 7227 HandleScope scope(isolate); |
7404 ASSERT(args.length() == 1); | 7228 ASSERT(args.length() == 1); |
7405 | 7229 |
7406 Handle<JSFunction> function = args.at<JSFunction>(0); | 7230 Handle<JSFunction> function = args.at<JSFunction>(0); |
7407 #ifdef DEBUG | 7231 #ifdef DEBUG |
7408 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 7232 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
7409 PrintF("[lazy: "); | 7233 PrintF("[lazy: "); |
7410 function->PrintName(); | 7234 function->PrintName(); |
7411 PrintF("]\n"); | 7235 PrintF("]\n"); |
7412 } | 7236 } |
(...skipping 10 matching lines...) Expand all Loading... |
7423 if (!CompileLazyInLoop(function, KEEP_EXCEPTION)) { | 7247 if (!CompileLazyInLoop(function, KEEP_EXCEPTION)) { |
7424 return Failure::Exception(); | 7248 return Failure::Exception(); |
7425 } | 7249 } |
7426 | 7250 |
7427 // All done. Return the compiled code. | 7251 // All done. Return the compiled code. |
7428 ASSERT(function->is_compiled()); | 7252 ASSERT(function->is_compiled()); |
7429 return function->code(); | 7253 return function->code(); |
7430 } | 7254 } |
7431 | 7255 |
7432 | 7256 |
7433 static MaybeObject* Runtime_LazyRecompile(RUNTIME_CALLING_CONVENTION) { | 7257 RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { |
7434 RUNTIME_GET_ISOLATE; | |
7435 HandleScope scope(isolate); | 7258 HandleScope scope(isolate); |
7436 ASSERT(args.length() == 1); | 7259 ASSERT(args.length() == 1); |
7437 Handle<JSFunction> function = args.at<JSFunction>(0); | 7260 Handle<JSFunction> function = args.at<JSFunction>(0); |
7438 // If the function is not optimizable or debugger is active continue using the | 7261 // If the function is not optimizable or debugger is active continue using the |
7439 // code from the full compiler. | 7262 // code from the full compiler. |
7440 if (!function->shared()->code()->optimizable() || | 7263 if (!function->shared()->code()->optimizable() || |
7441 isolate->debug()->has_break_points()) { | 7264 isolate->debug()->has_break_points()) { |
7442 if (FLAG_trace_opt) { | 7265 if (FLAG_trace_opt) { |
7443 PrintF("[failed to optimize "); | 7266 PrintF("[failed to optimize "); |
7444 function->PrintName(); | 7267 function->PrintName(); |
(...skipping 10 matching lines...) Expand all Loading... |
7455 if (FLAG_trace_opt) { | 7278 if (FLAG_trace_opt) { |
7456 PrintF("[failed to optimize "); | 7279 PrintF("[failed to optimize "); |
7457 function->PrintName(); | 7280 function->PrintName(); |
7458 PrintF(": optimized compilation failed]\n"); | 7281 PrintF(": optimized compilation failed]\n"); |
7459 } | 7282 } |
7460 function->ReplaceCode(function->shared()->code()); | 7283 function->ReplaceCode(function->shared()->code()); |
7461 return function->code(); | 7284 return function->code(); |
7462 } | 7285 } |
7463 | 7286 |
7464 | 7287 |
7465 static MaybeObject* Runtime_NotifyDeoptimized(RUNTIME_CALLING_CONVENTION) { | 7288 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { |
7466 RUNTIME_GET_ISOLATE; | |
7467 HandleScope scope(isolate); | 7289 HandleScope scope(isolate); |
7468 ASSERT(args.length() == 1); | 7290 ASSERT(args.length() == 1); |
7469 RUNTIME_ASSERT(args[0]->IsSmi()); | 7291 RUNTIME_ASSERT(args[0]->IsSmi()); |
7470 Deoptimizer::BailoutType type = | 7292 Deoptimizer::BailoutType type = |
7471 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); | 7293 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); |
7472 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 7294 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
7473 ASSERT(isolate->heap()->IsAllocationAllowed()); | 7295 ASSERT(isolate->heap()->IsAllocationAllowed()); |
7474 int frames = deoptimizer->output_count(); | 7296 int frames = deoptimizer->output_count(); |
7475 | 7297 |
7476 JavaScriptFrameIterator it; | 7298 JavaScriptFrameIterator it; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7530 PrintF("[removing optimized code for: "); | 7352 PrintF("[removing optimized code for: "); |
7531 function->PrintName(); | 7353 function->PrintName(); |
7532 PrintF("]\n"); | 7354 PrintF("]\n"); |
7533 } | 7355 } |
7534 function->ReplaceCode(function->shared()->code()); | 7356 function->ReplaceCode(function->shared()->code()); |
7535 } | 7357 } |
7536 return isolate->heap()->undefined_value(); | 7358 return isolate->heap()->undefined_value(); |
7537 } | 7359 } |
7538 | 7360 |
7539 | 7361 |
7540 static MaybeObject* Runtime_NotifyOSR(RUNTIME_CALLING_CONVENTION) { | 7362 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyOSR) { |
7541 RUNTIME_GET_ISOLATE; | |
7542 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 7363 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
7543 delete deoptimizer; | 7364 delete deoptimizer; |
7544 return isolate->heap()->undefined_value(); | 7365 return isolate->heap()->undefined_value(); |
7545 } | 7366 } |
7546 | 7367 |
7547 | 7368 |
7548 static MaybeObject* Runtime_DeoptimizeFunction(RUNTIME_CALLING_CONVENTION) { | 7369 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { |
7549 RUNTIME_GET_ISOLATE; | |
7550 HandleScope scope(isolate); | 7370 HandleScope scope(isolate); |
7551 ASSERT(args.length() == 1); | 7371 ASSERT(args.length() == 1); |
7552 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 7372 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
7553 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 7373 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
7554 | 7374 |
7555 Deoptimizer::DeoptimizeFunction(*function); | 7375 Deoptimizer::DeoptimizeFunction(*function); |
7556 | 7376 |
7557 return isolate->heap()->undefined_value(); | 7377 return isolate->heap()->undefined_value(); |
7558 } | 7378 } |
7559 | 7379 |
7560 | 7380 |
7561 static MaybeObject* Runtime_CompileForOnStackReplacement( | 7381 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
7562 RUNTIME_CALLING_CONVENTION) { | |
7563 RUNTIME_GET_ISOLATE; | |
7564 HandleScope scope(isolate); | 7382 HandleScope scope(isolate); |
7565 ASSERT(args.length() == 1); | 7383 ASSERT(args.length() == 1); |
7566 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 7384 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
7567 | 7385 |
7568 // We're not prepared to handle a function with arguments object. | 7386 // We're not prepared to handle a function with arguments object. |
7569 ASSERT(!function->shared()->scope_info()->HasArgumentsShadow()); | 7387 ASSERT(!function->shared()->scope_info()->HasArgumentsShadow()); |
7570 | 7388 |
7571 // We have hit a back edge in an unoptimized frame for a function that was | 7389 // We have hit a back edge in an unoptimized frame for a function that was |
7572 // selected for on-stack replacement. Find the unoptimized code object. | 7390 // selected for on-stack replacement. Find the unoptimized code object. |
7573 Handle<Code> unoptimized(function->shared()->code(), isolate); | 7391 Handle<Code> unoptimized(function->shared()->code(), isolate); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7667 return Smi::FromInt(ast_id); | 7485 return Smi::FromInt(ast_id); |
7668 } else { | 7486 } else { |
7669 if (function->IsMarkedForLazyRecompilation()) { | 7487 if (function->IsMarkedForLazyRecompilation()) { |
7670 function->ReplaceCode(function->shared()->code()); | 7488 function->ReplaceCode(function->shared()->code()); |
7671 } | 7489 } |
7672 return Smi::FromInt(-1); | 7490 return Smi::FromInt(-1); |
7673 } | 7491 } |
7674 } | 7492 } |
7675 | 7493 |
7676 | 7494 |
7677 static MaybeObject* Runtime_GetFunctionDelegate(RUNTIME_CALLING_CONVENTION) { | 7495 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { |
7678 RUNTIME_GET_ISOLATE; | |
7679 HandleScope scope(isolate); | 7496 HandleScope scope(isolate); |
7680 ASSERT(args.length() == 1); | 7497 ASSERT(args.length() == 1); |
7681 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 7498 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
7682 return *Execution::GetFunctionDelegate(args.at<Object>(0)); | 7499 return *Execution::GetFunctionDelegate(args.at<Object>(0)); |
7683 } | 7500 } |
7684 | 7501 |
7685 | 7502 |
7686 static MaybeObject* Runtime_GetConstructorDelegate(RUNTIME_CALLING_CONVENTION) { | 7503 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
7687 RUNTIME_GET_ISOLATE; | |
7688 HandleScope scope(isolate); | 7504 HandleScope scope(isolate); |
7689 ASSERT(args.length() == 1); | 7505 ASSERT(args.length() == 1); |
7690 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 7506 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
7691 return *Execution::GetConstructorDelegate(args.at<Object>(0)); | 7507 return *Execution::GetConstructorDelegate(args.at<Object>(0)); |
7692 } | 7508 } |
7693 | 7509 |
7694 | 7510 |
7695 static MaybeObject* Runtime_NewContext(RUNTIME_CALLING_CONVENTION) { | 7511 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewContext) { |
7696 RUNTIME_GET_ISOLATE; | |
7697 NoHandleAllocation ha; | 7512 NoHandleAllocation ha; |
7698 ASSERT(args.length() == 1); | 7513 ASSERT(args.length() == 1); |
7699 | 7514 |
7700 CONVERT_CHECKED(JSFunction, function, args[0]); | 7515 CONVERT_CHECKED(JSFunction, function, args[0]); |
7701 int length = function->shared()->scope_info()->NumberOfContextSlots(); | 7516 int length = function->shared()->scope_info()->NumberOfContextSlots(); |
7702 Object* result; | 7517 Object* result; |
7703 { MaybeObject* maybe_result = | 7518 { MaybeObject* maybe_result = |
7704 isolate->heap()->AllocateFunctionContext(length, function); | 7519 isolate->heap()->AllocateFunctionContext(length, function); |
7705 if (!maybe_result->ToObject(&result)) return maybe_result; | 7520 if (!maybe_result->ToObject(&result)) return maybe_result; |
7706 } | 7521 } |
(...skipping 30 matching lines...) Expand all Loading... |
7737 if (!maybe_result->ToObject(&result)) return maybe_result; | 7552 if (!maybe_result->ToObject(&result)) return maybe_result; |
7738 } | 7553 } |
7739 | 7554 |
7740 Context* context = Context::cast(result); | 7555 Context* context = Context::cast(result); |
7741 isolate->set_context(context); | 7556 isolate->set_context(context); |
7742 | 7557 |
7743 return result; | 7558 return result; |
7744 } | 7559 } |
7745 | 7560 |
7746 | 7561 |
7747 static MaybeObject* Runtime_PushContext(RUNTIME_CALLING_CONVENTION) { | 7562 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushContext) { |
7748 RUNTIME_GET_ISOLATE; | |
7749 NoHandleAllocation ha; | 7563 NoHandleAllocation ha; |
7750 ASSERT(args.length() == 1); | 7564 ASSERT(args.length() == 1); |
7751 return PushContextHelper(isolate, args[0], false); | 7565 return PushContextHelper(isolate, args[0], false); |
7752 } | 7566 } |
7753 | 7567 |
7754 | 7568 |
7755 static MaybeObject* Runtime_PushCatchContext(RUNTIME_CALLING_CONVENTION) { | 7569 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushCatchContext) { |
7756 RUNTIME_GET_ISOLATE; | |
7757 NoHandleAllocation ha; | 7570 NoHandleAllocation ha; |
7758 ASSERT(args.length() == 1); | 7571 ASSERT(args.length() == 1); |
7759 return PushContextHelper(isolate, args[0], true); | 7572 return PushContextHelper(isolate, args[0], true); |
7760 } | 7573 } |
7761 | 7574 |
7762 | 7575 |
7763 static MaybeObject* Runtime_DeleteContextSlot(RUNTIME_CALLING_CONVENTION) { | 7576 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteContextSlot) { |
7764 RUNTIME_GET_ISOLATE; | |
7765 HandleScope scope(isolate); | 7577 HandleScope scope(isolate); |
7766 ASSERT(args.length() == 2); | 7578 ASSERT(args.length() == 2); |
7767 | 7579 |
7768 CONVERT_ARG_CHECKED(Context, context, 0); | 7580 CONVERT_ARG_CHECKED(Context, context, 0); |
7769 CONVERT_ARG_CHECKED(String, name, 1); | 7581 CONVERT_ARG_CHECKED(String, name, 1); |
7770 | 7582 |
7771 int index; | 7583 int index; |
7772 PropertyAttributes attributes; | 7584 PropertyAttributes attributes; |
7773 ContextLookupFlags flags = FOLLOW_CHAINS; | 7585 ContextLookupFlags flags = FOLLOW_CHAINS; |
7774 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); | 7586 Handle<Object> holder = context->Lookup(name, flags, &index, &attributes); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7914 HandleVector(&name, 1)); | 7726 HandleVector(&name, 1)); |
7915 return MakePair(isolate->Throw(*reference_error), NULL); | 7727 return MakePair(isolate->Throw(*reference_error), NULL); |
7916 } else { | 7728 } else { |
7917 // The property doesn't exist - return undefined | 7729 // The property doesn't exist - return undefined |
7918 return MakePair(isolate->heap()->undefined_value(), | 7730 return MakePair(isolate->heap()->undefined_value(), |
7919 isolate->heap()->undefined_value()); | 7731 isolate->heap()->undefined_value()); |
7920 } | 7732 } |
7921 } | 7733 } |
7922 | 7734 |
7923 | 7735 |
7924 static ObjectPair Runtime_LoadContextSlot(RUNTIME_CALLING_CONVENTION) { | 7736 RUNTIME_FUNCTION(ObjectPair, Runtime_LoadContextSlot) { |
7925 RUNTIME_GET_ISOLATE; | |
7926 return LoadContextSlotHelper(args, isolate, true); | 7737 return LoadContextSlotHelper(args, isolate, true); |
7927 } | 7738 } |
7928 | 7739 |
7929 | 7740 |
7930 static ObjectPair Runtime_LoadContextSlotNoReferenceError( | 7741 RUNTIME_FUNCTION(ObjectPair, Runtime_LoadContextSlotNoReferenceError) { |
7931 RUNTIME_CALLING_CONVENTION) { | |
7932 RUNTIME_GET_ISOLATE; | |
7933 return LoadContextSlotHelper(args, isolate, false); | 7742 return LoadContextSlotHelper(args, isolate, false); |
7934 } | 7743 } |
7935 | 7744 |
7936 | 7745 |
7937 static MaybeObject* Runtime_StoreContextSlot(RUNTIME_CALLING_CONVENTION) { | 7746 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { |
7938 RUNTIME_GET_ISOLATE; | |
7939 HandleScope scope(isolate); | 7747 HandleScope scope(isolate); |
7940 ASSERT(args.length() == 4); | 7748 ASSERT(args.length() == 4); |
7941 | 7749 |
7942 Handle<Object> value(args[0], isolate); | 7750 Handle<Object> value(args[0], isolate); |
7943 CONVERT_ARG_CHECKED(Context, context, 1); | 7751 CONVERT_ARG_CHECKED(Context, context, 1); |
7944 CONVERT_ARG_CHECKED(String, name, 2); | 7752 CONVERT_ARG_CHECKED(String, name, 2); |
7945 CONVERT_SMI_CHECKED(strict_unchecked, args[3]); | 7753 CONVERT_SMI_CHECKED(strict_unchecked, args[3]); |
7946 RUNTIME_ASSERT(strict_unchecked == kStrictMode || | 7754 RUNTIME_ASSERT(strict_unchecked == kStrictMode || |
7947 strict_unchecked == kNonStrictMode); | 7755 strict_unchecked == kNonStrictMode); |
7948 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(strict_unchecked); | 7756 StrictModeFlag strict_mode = static_cast<StrictModeFlag>(strict_unchecked); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8002 // Setting read only property in strict mode. | 7810 // Setting read only property in strict mode. |
8003 Handle<Object> error = | 7811 Handle<Object> error = |
8004 isolate->factory()->NewTypeError( | 7812 isolate->factory()->NewTypeError( |
8005 "strict_cannot_assign", HandleVector(&name, 1)); | 7813 "strict_cannot_assign", HandleVector(&name, 1)); |
8006 return isolate->Throw(*error); | 7814 return isolate->Throw(*error); |
8007 } | 7815 } |
8008 return *value; | 7816 return *value; |
8009 } | 7817 } |
8010 | 7818 |
8011 | 7819 |
8012 static MaybeObject* Runtime_Throw(RUNTIME_CALLING_CONVENTION) { | 7820 RUNTIME_FUNCTION(MaybeObject*, Runtime_Throw) { |
8013 RUNTIME_GET_ISOLATE; | |
8014 HandleScope scope(isolate); | 7821 HandleScope scope(isolate); |
8015 ASSERT(args.length() == 1); | 7822 ASSERT(args.length() == 1); |
8016 | 7823 |
8017 return isolate->Throw(args[0]); | 7824 return isolate->Throw(args[0]); |
8018 } | 7825 } |
8019 | 7826 |
8020 | 7827 |
8021 static MaybeObject* Runtime_ReThrow(RUNTIME_CALLING_CONVENTION) { | 7828 RUNTIME_FUNCTION(MaybeObject*, Runtime_ReThrow) { |
8022 RUNTIME_GET_ISOLATE; | |
8023 HandleScope scope(isolate); | 7829 HandleScope scope(isolate); |
8024 ASSERT(args.length() == 1); | 7830 ASSERT(args.length() == 1); |
8025 | 7831 |
8026 return isolate->ReThrow(args[0]); | 7832 return isolate->ReThrow(args[0]); |
8027 } | 7833 } |
8028 | 7834 |
8029 | 7835 |
8030 static MaybeObject* Runtime_PromoteScheduledException( | 7836 RUNTIME_FUNCTION(MaybeObject*, Runtime_PromoteScheduledException) { |
8031 RUNTIME_CALLING_CONVENTION) { | |
8032 RUNTIME_GET_ISOLATE; | |
8033 ASSERT_EQ(0, args.length()); | 7837 ASSERT_EQ(0, args.length()); |
8034 return isolate->PromoteScheduledException(); | 7838 return isolate->PromoteScheduledException(); |
8035 } | 7839 } |
8036 | 7840 |
8037 | 7841 |
8038 static MaybeObject* Runtime_ThrowReferenceError(RUNTIME_CALLING_CONVENTION) { | 7842 RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) { |
8039 RUNTIME_GET_ISOLATE; | |
8040 HandleScope scope(isolate); | 7843 HandleScope scope(isolate); |
8041 ASSERT(args.length() == 1); | 7844 ASSERT(args.length() == 1); |
8042 | 7845 |
8043 Handle<Object> name(args[0], isolate); | 7846 Handle<Object> name(args[0], isolate); |
8044 Handle<Object> reference_error = | 7847 Handle<Object> reference_error = |
8045 isolate->factory()->NewReferenceError("not_defined", | 7848 isolate->factory()->NewReferenceError("not_defined", |
8046 HandleVector(&name, 1)); | 7849 HandleVector(&name, 1)); |
8047 return isolate->Throw(*reference_error); | 7850 return isolate->Throw(*reference_error); |
8048 } | 7851 } |
8049 | 7852 |
8050 | 7853 |
8051 static MaybeObject* Runtime_StackGuard(RUNTIME_CALLING_CONVENTION) { | 7854 RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
8052 RUNTIME_GET_ISOLATE; | |
8053 ASSERT(args.length() == 0); | 7855 ASSERT(args.length() == 0); |
8054 | 7856 |
8055 // First check if this is a real stack overflow. | 7857 // First check if this is a real stack overflow. |
8056 if (isolate->stack_guard()->IsStackOverflow()) { | 7858 if (isolate->stack_guard()->IsStackOverflow()) { |
8057 NoHandleAllocation na; | 7859 NoHandleAllocation na; |
8058 return isolate->StackOverflow(); | 7860 return isolate->StackOverflow(); |
8059 } | 7861 } |
8060 | 7862 |
8061 return Execution::HandleStackGuardInterrupt(); | 7863 return Execution::HandleStackGuardInterrupt(); |
8062 } | 7864 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8141 | 7943 |
8142 } else { | 7944 } else { |
8143 // function result | 7945 // function result |
8144 PrintF("} -> "); | 7946 PrintF("} -> "); |
8145 PrintObject(result); | 7947 PrintObject(result); |
8146 PrintF("\n"); | 7948 PrintF("\n"); |
8147 } | 7949 } |
8148 } | 7950 } |
8149 | 7951 |
8150 | 7952 |
8151 static MaybeObject* Runtime_TraceEnter(RUNTIME_CALLING_CONVENTION) { | 7953 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { |
8152 RUNTIME_GET_ISOLATE; | |
8153 ASSERT(args.length() == 0); | 7954 ASSERT(args.length() == 0); |
8154 NoHandleAllocation ha; | 7955 NoHandleAllocation ha; |
8155 PrintTransition(NULL); | 7956 PrintTransition(NULL); |
8156 return isolate->heap()->undefined_value(); | 7957 return isolate->heap()->undefined_value(); |
8157 } | 7958 } |
8158 | 7959 |
8159 | 7960 |
8160 static MaybeObject* Runtime_TraceExit(RUNTIME_CALLING_CONVENTION) { | 7961 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { |
8161 RUNTIME_GET_ISOLATE; | |
8162 NoHandleAllocation ha; | 7962 NoHandleAllocation ha; |
8163 PrintTransition(args[0]); | 7963 PrintTransition(args[0]); |
8164 return args[0]; // return TOS | 7964 return args[0]; // return TOS |
8165 } | 7965 } |
8166 | 7966 |
8167 | 7967 |
8168 static MaybeObject* Runtime_DebugPrint(RUNTIME_CALLING_CONVENTION) { | 7968 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { |
8169 RUNTIME_GET_ISOLATE; | |
8170 NoHandleAllocation ha; | 7969 NoHandleAllocation ha; |
8171 ASSERT(args.length() == 1); | 7970 ASSERT(args.length() == 1); |
8172 | 7971 |
8173 #ifdef DEBUG | 7972 #ifdef DEBUG |
8174 if (args[0]->IsString()) { | 7973 if (args[0]->IsString()) { |
8175 // If we have a string, assume it's a code "marker" | 7974 // If we have a string, assume it's a code "marker" |
8176 // and print some interesting cpu debugging info. | 7975 // and print some interesting cpu debugging info. |
8177 JavaScriptFrameIterator it; | 7976 JavaScriptFrameIterator it; |
8178 JavaScriptFrame* frame = it.frame(); | 7977 JavaScriptFrame* frame = it.frame(); |
8179 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 7978 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
(...skipping 10 matching lines...) Expand all Loading... |
8190 // ShortPrint is available in release mode. Print is not. | 7989 // ShortPrint is available in release mode. Print is not. |
8191 args[0]->ShortPrint(); | 7990 args[0]->ShortPrint(); |
8192 #endif | 7991 #endif |
8193 PrintF("\n"); | 7992 PrintF("\n"); |
8194 Flush(); | 7993 Flush(); |
8195 | 7994 |
8196 return args[0]; // return TOS | 7995 return args[0]; // return TOS |
8197 } | 7996 } |
8198 | 7997 |
8199 | 7998 |
8200 static MaybeObject* Runtime_DebugTrace(RUNTIME_CALLING_CONVENTION) { | 7999 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { |
8201 RUNTIME_GET_ISOLATE; | |
8202 ASSERT(args.length() == 0); | 8000 ASSERT(args.length() == 0); |
8203 NoHandleAllocation ha; | 8001 NoHandleAllocation ha; |
8204 isolate->PrintStack(); | 8002 isolate->PrintStack(); |
8205 return isolate->heap()->undefined_value(); | 8003 return isolate->heap()->undefined_value(); |
8206 } | 8004 } |
8207 | 8005 |
8208 | 8006 |
8209 static MaybeObject* Runtime_DateCurrentTime(RUNTIME_CALLING_CONVENTION) { | 8007 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
8210 RUNTIME_GET_ISOLATE; | |
8211 NoHandleAllocation ha; | 8008 NoHandleAllocation ha; |
8212 ASSERT(args.length() == 0); | 8009 ASSERT(args.length() == 0); |
8213 | 8010 |
8214 // According to ECMA-262, section 15.9.1, page 117, the precision of | 8011 // According to ECMA-262, section 15.9.1, page 117, the precision of |
8215 // the number in a Date object representing a particular instant in | 8012 // the number in a Date object representing a particular instant in |
8216 // time is milliseconds. Therefore, we floor the result of getting | 8013 // time is milliseconds. Therefore, we floor the result of getting |
8217 // the OS time. | 8014 // the OS time. |
8218 double millis = floor(OS::TimeCurrentMillis()); | 8015 double millis = floor(OS::TimeCurrentMillis()); |
8219 return isolate->heap()->NumberFromDouble(millis); | 8016 return isolate->heap()->NumberFromDouble(millis); |
8220 } | 8017 } |
8221 | 8018 |
8222 | 8019 |
8223 static MaybeObject* Runtime_DateParseString(RUNTIME_CALLING_CONVENTION) { | 8020 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { |
8224 RUNTIME_GET_ISOLATE; | |
8225 HandleScope scope(isolate); | 8021 HandleScope scope(isolate); |
8226 ASSERT(args.length() == 2); | 8022 ASSERT(args.length() == 2); |
8227 | 8023 |
8228 CONVERT_ARG_CHECKED(String, str, 0); | 8024 CONVERT_ARG_CHECKED(String, str, 0); |
8229 FlattenString(str); | 8025 FlattenString(str); |
8230 | 8026 |
8231 CONVERT_ARG_CHECKED(JSArray, output, 1); | 8027 CONVERT_ARG_CHECKED(JSArray, output, 1); |
8232 RUNTIME_ASSERT(output->HasFastElements()); | 8028 RUNTIME_ASSERT(output->HasFastElements()); |
8233 | 8029 |
8234 AssertNoAllocation no_allocation; | 8030 AssertNoAllocation no_allocation; |
8235 | 8031 |
8236 FixedArray* output_array = FixedArray::cast(output->elements()); | 8032 FixedArray* output_array = FixedArray::cast(output->elements()); |
8237 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); | 8033 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); |
8238 bool result; | 8034 bool result; |
8239 if (str->IsAsciiRepresentation()) { | 8035 if (str->IsAsciiRepresentation()) { |
8240 result = DateParser::Parse(str->ToAsciiVector(), output_array); | 8036 result = DateParser::Parse(str->ToAsciiVector(), output_array); |
8241 } else { | 8037 } else { |
8242 ASSERT(str->IsTwoByteRepresentation()); | 8038 ASSERT(str->IsTwoByteRepresentation()); |
8243 result = DateParser::Parse(str->ToUC16Vector(), output_array); | 8039 result = DateParser::Parse(str->ToUC16Vector(), output_array); |
8244 } | 8040 } |
8245 | 8041 |
8246 if (result) { | 8042 if (result) { |
8247 return *output; | 8043 return *output; |
8248 } else { | 8044 } else { |
8249 return isolate->heap()->null_value(); | 8045 return isolate->heap()->null_value(); |
8250 } | 8046 } |
8251 } | 8047 } |
8252 | 8048 |
8253 | 8049 |
8254 static MaybeObject* Runtime_DateLocalTimezone(RUNTIME_CALLING_CONVENTION) { | 8050 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
8255 RUNTIME_GET_ISOLATE; | |
8256 NoHandleAllocation ha; | 8051 NoHandleAllocation ha; |
8257 ASSERT(args.length() == 1); | 8052 ASSERT(args.length() == 1); |
8258 | 8053 |
8259 CONVERT_DOUBLE_CHECKED(x, args[0]); | 8054 CONVERT_DOUBLE_CHECKED(x, args[0]); |
8260 const char* zone = OS::LocalTimezone(x); | 8055 const char* zone = OS::LocalTimezone(x); |
8261 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 8056 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
8262 } | 8057 } |
8263 | 8058 |
8264 | 8059 |
8265 static MaybeObject* Runtime_DateLocalTimeOffset(RUNTIME_CALLING_CONVENTION) { | 8060 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimeOffset) { |
8266 RUNTIME_GET_ISOLATE; | |
8267 NoHandleAllocation ha; | 8061 NoHandleAllocation ha; |
8268 ASSERT(args.length() == 0); | 8062 ASSERT(args.length() == 0); |
8269 | 8063 |
8270 return isolate->heap()->NumberFromDouble(OS::LocalTimeOffset()); | 8064 return isolate->heap()->NumberFromDouble(OS::LocalTimeOffset()); |
8271 } | 8065 } |
8272 | 8066 |
8273 | 8067 |
8274 static MaybeObject* Runtime_DateDaylightSavingsOffset( | 8068 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateDaylightSavingsOffset) { |
8275 RUNTIME_CALLING_CONVENTION) { | |
8276 RUNTIME_GET_ISOLATE; | |
8277 NoHandleAllocation ha; | 8069 NoHandleAllocation ha; |
8278 ASSERT(args.length() == 1); | 8070 ASSERT(args.length() == 1); |
8279 | 8071 |
8280 CONVERT_DOUBLE_CHECKED(x, args[0]); | 8072 CONVERT_DOUBLE_CHECKED(x, args[0]); |
8281 return isolate->heap()->NumberFromDouble(OS::DaylightSavingsOffset(x)); | 8073 return isolate->heap()->NumberFromDouble(OS::DaylightSavingsOffset(x)); |
8282 } | 8074 } |
8283 | 8075 |
8284 | 8076 |
8285 static MaybeObject* Runtime_GlobalReceiver(RUNTIME_CALLING_CONVENTION) { | 8077 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
8286 RUNTIME_GET_ISOLATE; | |
8287 ASSERT(args.length() == 1); | 8078 ASSERT(args.length() == 1); |
8288 Object* global = args[0]; | 8079 Object* global = args[0]; |
8289 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 8080 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
8290 return JSGlobalObject::cast(global)->global_receiver(); | 8081 return JSGlobalObject::cast(global)->global_receiver(); |
8291 } | 8082 } |
8292 | 8083 |
8293 | 8084 |
8294 static MaybeObject* Runtime_ParseJson(RUNTIME_CALLING_CONVENTION) { | 8085 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { |
8295 HandleScope scope(isolate); | 8086 HandleScope scope(isolate); |
8296 ASSERT_EQ(1, args.length()); | 8087 ASSERT_EQ(1, args.length()); |
8297 CONVERT_ARG_CHECKED(String, source, 0); | 8088 CONVERT_ARG_CHECKED(String, source, 0); |
8298 | 8089 |
8299 Handle<Object> result = JsonParser::Parse(source); | 8090 Handle<Object> result = JsonParser::Parse(source); |
8300 if (result.is_null()) { | 8091 if (result.is_null()) { |
8301 // Syntax error or stack overflow in scanner. | 8092 // Syntax error or stack overflow in scanner. |
8302 ASSERT(isolate->has_pending_exception()); | 8093 ASSERT(isolate->has_pending_exception()); |
8303 return Failure::Exception(); | 8094 return Failure::Exception(); |
8304 } | 8095 } |
8305 return *result; | 8096 return *result; |
8306 } | 8097 } |
8307 | 8098 |
8308 | 8099 |
8309 static MaybeObject* Runtime_CompileString(RUNTIME_CALLING_CONVENTION) { | 8100 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { |
8310 RUNTIME_GET_ISOLATE; | |
8311 HandleScope scope(isolate); | 8101 HandleScope scope(isolate); |
8312 ASSERT_EQ(1, args.length()); | 8102 ASSERT_EQ(1, args.length()); |
8313 CONVERT_ARG_CHECKED(String, source, 0); | 8103 CONVERT_ARG_CHECKED(String, source, 0); |
8314 | 8104 |
8315 // Compile source string in the global context. | 8105 // Compile source string in the global context. |
8316 Handle<Context> context(isolate->context()->global_context()); | 8106 Handle<Context> context(isolate->context()->global_context()); |
8317 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source, | 8107 Handle<SharedFunctionInfo> shared = Compiler::CompileEval(source, |
8318 context, | 8108 context, |
8319 true, | 8109 true, |
8320 kNonStrictMode); | 8110 kNonStrictMode); |
(...skipping 18 matching lines...) Expand all Loading... |
8339 isolate->context()->IsGlobalContext(), | 8129 isolate->context()->IsGlobalContext(), |
8340 strict_mode); | 8130 strict_mode); |
8341 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); | 8131 if (shared.is_null()) return MakePair(Failure::Exception(), NULL); |
8342 Handle<JSFunction> compiled = | 8132 Handle<JSFunction> compiled = |
8343 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8133 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
8344 shared, Handle<Context>(isolate->context()), NOT_TENURED); | 8134 shared, Handle<Context>(isolate->context()), NOT_TENURED); |
8345 return MakePair(*compiled, *receiver); | 8135 return MakePair(*compiled, *receiver); |
8346 } | 8136 } |
8347 | 8137 |
8348 | 8138 |
8349 static ObjectPair Runtime_ResolvePossiblyDirectEval( | 8139 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEval) { |
8350 RUNTIME_CALLING_CONVENTION) { | |
8351 RUNTIME_GET_ISOLATE; | |
8352 ASSERT(args.length() == 4); | 8140 ASSERT(args.length() == 4); |
8353 | 8141 |
8354 HandleScope scope(isolate); | 8142 HandleScope scope(isolate); |
8355 Handle<Object> callee = args.at<Object>(0); | 8143 Handle<Object> callee = args.at<Object>(0); |
8356 Handle<Object> receiver; // Will be overwritten. | 8144 Handle<Object> receiver; // Will be overwritten. |
8357 | 8145 |
8358 // Compute the calling context. | 8146 // Compute the calling context. |
8359 Handle<Context> context = Handle<Context>(isolate->context(), isolate); | 8147 Handle<Context> context = Handle<Context>(isolate->context(), isolate); |
8360 #ifdef DEBUG | 8148 #ifdef DEBUG |
8361 // Make sure Isolate::context() agrees with the old code that traversed | 8149 // Make sure Isolate::context() agrees with the old code that traversed |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8417 | 8205 |
8418 ASSERT(args[3]->IsSmi()); | 8206 ASSERT(args[3]->IsSmi()); |
8419 return CompileGlobalEval(isolate, | 8207 return CompileGlobalEval(isolate, |
8420 args.at<String>(1), | 8208 args.at<String>(1), |
8421 args.at<Object>(2), | 8209 args.at<Object>(2), |
8422 static_cast<StrictModeFlag>( | 8210 static_cast<StrictModeFlag>( |
8423 Smi::cast(args[3])->value())); | 8211 Smi::cast(args[3])->value())); |
8424 } | 8212 } |
8425 | 8213 |
8426 | 8214 |
8427 static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup( | 8215 RUNTIME_FUNCTION(ObjectPair, Runtime_ResolvePossiblyDirectEvalNoLookup) { |
8428 RUNTIME_CALLING_CONVENTION) { | |
8429 RUNTIME_GET_ISOLATE; | |
8430 ASSERT(args.length() == 4); | 8216 ASSERT(args.length() == 4); |
8431 | 8217 |
8432 HandleScope scope(isolate); | 8218 HandleScope scope(isolate); |
8433 Handle<Object> callee = args.at<Object>(0); | 8219 Handle<Object> callee = args.at<Object>(0); |
8434 | 8220 |
8435 // 'eval' is bound in the global context, but it may have been overwritten. | 8221 // 'eval' is bound in the global context, but it may have been overwritten. |
8436 // Compare it to the builtin 'GlobalEval' function to make sure. | 8222 // Compare it to the builtin 'GlobalEval' function to make sure. |
8437 if (*callee != isolate->global_context()->global_eval_fun() || | 8223 if (*callee != isolate->global_context()->global_eval_fun() || |
8438 !args[1]->IsString()) { | 8224 !args[1]->IsString()) { |
8439 return MakePair(*callee, | 8225 return MakePair(*callee, |
8440 isolate->context()->global()->global_receiver()); | 8226 isolate->context()->global()->global_receiver()); |
8441 } | 8227 } |
8442 | 8228 |
8443 ASSERT(args[3]->IsSmi()); | 8229 ASSERT(args[3]->IsSmi()); |
8444 return CompileGlobalEval(isolate, | 8230 return CompileGlobalEval(isolate, |
8445 args.at<String>(1), | 8231 args.at<String>(1), |
8446 args.at<Object>(2), | 8232 args.at<Object>(2), |
8447 static_cast<StrictModeFlag>( | 8233 static_cast<StrictModeFlag>( |
8448 Smi::cast(args[3])->value())); | 8234 Smi::cast(args[3])->value())); |
8449 } | 8235 } |
8450 | 8236 |
8451 | 8237 |
8452 static MaybeObject* Runtime_SetNewFunctionAttributes( | 8238 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNewFunctionAttributes) { |
8453 RUNTIME_CALLING_CONVENTION) { | |
8454 RUNTIME_GET_ISOLATE; | |
8455 // This utility adjusts the property attributes for newly created Function | 8239 // This utility adjusts the property attributes for newly created Function |
8456 // object ("new Function(...)") by changing the map. | 8240 // object ("new Function(...)") by changing the map. |
8457 // All it does is changing the prototype property to enumerable | 8241 // All it does is changing the prototype property to enumerable |
8458 // as specified in ECMA262, 15.3.5.2. | 8242 // as specified in ECMA262, 15.3.5.2. |
8459 HandleScope scope(isolate); | 8243 HandleScope scope(isolate); |
8460 ASSERT(args.length() == 1); | 8244 ASSERT(args.length() == 1); |
8461 CONVERT_ARG_CHECKED(JSFunction, func, 0); | 8245 CONVERT_ARG_CHECKED(JSFunction, func, 0); |
8462 | 8246 |
8463 Handle<Map> map = func->shared()->strict_mode() | 8247 Handle<Map> map = func->shared()->strict_mode() |
8464 ? isolate->strict_mode_function_instance_map() | 8248 ? isolate->strict_mode_function_instance_map() |
8465 : isolate->function_instance_map(); | 8249 : isolate->function_instance_map(); |
8466 | 8250 |
8467 ASSERT(func->map()->instance_type() == map->instance_type()); | 8251 ASSERT(func->map()->instance_type() == map->instance_type()); |
8468 ASSERT(func->map()->instance_size() == map->instance_size()); | 8252 ASSERT(func->map()->instance_size() == map->instance_size()); |
8469 func->set_map(*map); | 8253 func->set_map(*map); |
8470 return *func; | 8254 return *func; |
8471 } | 8255 } |
8472 | 8256 |
8473 | 8257 |
8474 static MaybeObject* Runtime_AllocateInNewSpace(RUNTIME_CALLING_CONVENTION) { | 8258 RUNTIME_FUNCTION(MaybeObject*, Runtime_AllocateInNewSpace) { |
8475 RUNTIME_GET_ISOLATE; | |
8476 // Allocate a block of memory in NewSpace (filled with a filler). | 8259 // Allocate a block of memory in NewSpace (filled with a filler). |
8477 // Use as fallback for allocation in generated code when NewSpace | 8260 // Use as fallback for allocation in generated code when NewSpace |
8478 // is full. | 8261 // is full. |
8479 ASSERT(args.length() == 1); | 8262 ASSERT(args.length() == 1); |
8480 CONVERT_ARG_CHECKED(Smi, size_smi, 0); | 8263 CONVERT_ARG_CHECKED(Smi, size_smi, 0); |
8481 int size = size_smi->value(); | 8264 int size = size_smi->value(); |
8482 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 8265 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
8483 RUNTIME_ASSERT(size > 0); | 8266 RUNTIME_ASSERT(size > 0); |
8484 Heap* heap = isolate->heap(); | 8267 Heap* heap = isolate->heap(); |
8485 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4; | 8268 const int kMinFreeNewSpaceAfterGC = heap->InitialSemiSpaceSize() * 3/4; |
8486 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC); | 8269 RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC); |
8487 Object* allocation; | 8270 Object* allocation; |
8488 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size); | 8271 { MaybeObject* maybe_allocation = heap->new_space()->AllocateRaw(size); |
8489 if (maybe_allocation->ToObject(&allocation)) { | 8272 if (maybe_allocation->ToObject(&allocation)) { |
8490 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); | 8273 heap->CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size); |
8491 } | 8274 } |
8492 return maybe_allocation; | 8275 return maybe_allocation; |
8493 } | 8276 } |
8494 } | 8277 } |
8495 | 8278 |
8496 | 8279 |
8497 // Push an object unto an array of objects if it is not already in the | 8280 // Push an object unto an array of objects if it is not already in the |
8498 // array. Returns true if the element was pushed on the stack and | 8281 // array. Returns true if the element was pushed on the stack and |
8499 // false otherwise. | 8282 // false otherwise. |
8500 static MaybeObject* Runtime_PushIfAbsent(RUNTIME_CALLING_CONVENTION) { | 8283 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { |
8501 RUNTIME_GET_ISOLATE; | |
8502 ASSERT(args.length() == 2); | 8284 ASSERT(args.length() == 2); |
8503 CONVERT_CHECKED(JSArray, array, args[0]); | 8285 CONVERT_CHECKED(JSArray, array, args[0]); |
8504 CONVERT_CHECKED(JSObject, element, args[1]); | 8286 CONVERT_CHECKED(JSObject, element, args[1]); |
8505 RUNTIME_ASSERT(array->HasFastElements()); | 8287 RUNTIME_ASSERT(array->HasFastElements()); |
8506 int length = Smi::cast(array->length())->value(); | 8288 int length = Smi::cast(array->length())->value(); |
8507 FixedArray* elements = FixedArray::cast(array->elements()); | 8289 FixedArray* elements = FixedArray::cast(array->elements()); |
8508 for (int i = 0; i < length; i++) { | 8290 for (int i = 0; i < length; i++) { |
8509 if (elements->get(i) == element) return isolate->heap()->false_value(); | 8291 if (elements->get(i) == element) return isolate->heap()->false_value(); |
8510 } | 8292 } |
8511 Object* obj; | 8293 Object* obj; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8940 return true; | 8722 return true; |
8941 } | 8723 } |
8942 | 8724 |
8943 | 8725 |
8944 /** | 8726 /** |
8945 * Array::concat implementation. | 8727 * Array::concat implementation. |
8946 * See ECMAScript 262, 15.4.4.4. | 8728 * See ECMAScript 262, 15.4.4.4. |
8947 * TODO(581): Fix non-compliance for very large concatenations and update to | 8729 * TODO(581): Fix non-compliance for very large concatenations and update to |
8948 * following the ECMAScript 5 specification. | 8730 * following the ECMAScript 5 specification. |
8949 */ | 8731 */ |
8950 static MaybeObject* Runtime_ArrayConcat(RUNTIME_CALLING_CONVENTION) { | 8732 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { |
8951 RUNTIME_GET_ISOLATE; | |
8952 ASSERT(args.length() == 1); | 8733 ASSERT(args.length() == 1); |
8953 HandleScope handle_scope(isolate); | 8734 HandleScope handle_scope(isolate); |
8954 | 8735 |
8955 CONVERT_ARG_CHECKED(JSArray, arguments, 0); | 8736 CONVERT_ARG_CHECKED(JSArray, arguments, 0); |
8956 int argument_count = static_cast<int>(arguments->length()->Number()); | 8737 int argument_count = static_cast<int>(arguments->length()->Number()); |
8957 RUNTIME_ASSERT(arguments->HasFastElements()); | 8738 RUNTIME_ASSERT(arguments->HasFastElements()); |
8958 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); | 8739 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); |
8959 | 8740 |
8960 // Pass 1: estimate the length and number of elements of the result. | 8741 // Pass 1: estimate the length and number of elements of the result. |
8961 // The actual length can be larger if any of the arguments have getters | 8742 // The actual length can be larger if any of the arguments have getters |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9029 visitor.increase_index_offset(1); | 8810 visitor.increase_index_offset(1); |
9030 } | 8811 } |
9031 } | 8812 } |
9032 | 8813 |
9033 return *visitor.ToArray(); | 8814 return *visitor.ToArray(); |
9034 } | 8815 } |
9035 | 8816 |
9036 | 8817 |
9037 // This will not allocate (flatten the string), but it may run | 8818 // This will not allocate (flatten the string), but it may run |
9038 // very slowly for very deeply nested ConsStrings. For debugging use only. | 8819 // very slowly for very deeply nested ConsStrings. For debugging use only. |
9039 static MaybeObject* Runtime_GlobalPrint(RUNTIME_CALLING_CONVENTION) { | 8820 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { |
9040 RUNTIME_GET_ISOLATE; | |
9041 NoHandleAllocation ha; | 8821 NoHandleAllocation ha; |
9042 ASSERT(args.length() == 1); | 8822 ASSERT(args.length() == 1); |
9043 | 8823 |
9044 CONVERT_CHECKED(String, string, args[0]); | 8824 CONVERT_CHECKED(String, string, args[0]); |
9045 StringInputBuffer buffer(string); | 8825 StringInputBuffer buffer(string); |
9046 while (buffer.has_more()) { | 8826 while (buffer.has_more()) { |
9047 uint16_t character = buffer.GetNext(); | 8827 uint16_t character = buffer.GetNext(); |
9048 PrintF("%c", character); | 8828 PrintF("%c", character); |
9049 } | 8829 } |
9050 return string; | 8830 return string; |
9051 } | 8831 } |
9052 | 8832 |
9053 // Moves all own elements of an object, that are below a limit, to positions | 8833 // Moves all own elements of an object, that are below a limit, to positions |
9054 // starting at zero. All undefined values are placed after non-undefined values, | 8834 // starting at zero. All undefined values are placed after non-undefined values, |
9055 // and are followed by non-existing element. Does not change the length | 8835 // and are followed by non-existing element. Does not change the length |
9056 // property. | 8836 // property. |
9057 // Returns the number of non-undefined elements collected. | 8837 // Returns the number of non-undefined elements collected. |
9058 static MaybeObject* Runtime_RemoveArrayHoles(RUNTIME_CALLING_CONVENTION) { | 8838 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { |
9059 RUNTIME_GET_ISOLATE; | |
9060 ASSERT(args.length() == 2); | 8839 ASSERT(args.length() == 2); |
9061 CONVERT_CHECKED(JSObject, object, args[0]); | 8840 CONVERT_CHECKED(JSObject, object, args[0]); |
9062 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 8841 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
9063 return object->PrepareElementsForSort(limit); | 8842 return object->PrepareElementsForSort(limit); |
9064 } | 8843 } |
9065 | 8844 |
9066 | 8845 |
9067 // Move contents of argument 0 (an array) to argument 1 (an array) | 8846 // Move contents of argument 0 (an array) to argument 1 (an array) |
9068 static MaybeObject* Runtime_MoveArrayContents(RUNTIME_CALLING_CONVENTION) { | 8847 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { |
9069 RUNTIME_GET_ISOLATE; | |
9070 ASSERT(args.length() == 2); | 8848 ASSERT(args.length() == 2); |
9071 CONVERT_CHECKED(JSArray, from, args[0]); | 8849 CONVERT_CHECKED(JSArray, from, args[0]); |
9072 CONVERT_CHECKED(JSArray, to, args[1]); | 8850 CONVERT_CHECKED(JSArray, to, args[1]); |
9073 HeapObject* new_elements = from->elements(); | 8851 HeapObject* new_elements = from->elements(); |
9074 MaybeObject* maybe_new_map; | 8852 MaybeObject* maybe_new_map; |
9075 if (new_elements->map() == isolate->heap()->fixed_array_map() || | 8853 if (new_elements->map() == isolate->heap()->fixed_array_map() || |
9076 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 8854 new_elements->map() == isolate->heap()->fixed_cow_array_map()) { |
9077 maybe_new_map = to->map()->GetFastElementsMap(); | 8855 maybe_new_map = to->map()->GetFastElementsMap(); |
9078 } else { | 8856 } else { |
9079 maybe_new_map = to->map()->GetSlowElementsMap(); | 8857 maybe_new_map = to->map()->GetSlowElementsMap(); |
9080 } | 8858 } |
9081 Object* new_map; | 8859 Object* new_map; |
9082 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 8860 if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; |
9083 to->set_map(Map::cast(new_map)); | 8861 to->set_map(Map::cast(new_map)); |
9084 to->set_elements(new_elements); | 8862 to->set_elements(new_elements); |
9085 to->set_length(from->length()); | 8863 to->set_length(from->length()); |
9086 Object* obj; | 8864 Object* obj; |
9087 { MaybeObject* maybe_obj = from->ResetElements(); | 8865 { MaybeObject* maybe_obj = from->ResetElements(); |
9088 if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 8866 if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
9089 } | 8867 } |
9090 from->set_length(Smi::FromInt(0)); | 8868 from->set_length(Smi::FromInt(0)); |
9091 return to; | 8869 return to; |
9092 } | 8870 } |
9093 | 8871 |
9094 | 8872 |
9095 // How many elements does this object/array have? | 8873 // How many elements does this object/array have? |
9096 static MaybeObject* Runtime_EstimateNumberOfElements( | 8874 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { |
9097 RUNTIME_CALLING_CONVENTION) { | |
9098 RUNTIME_GET_ISOLATE; | |
9099 ASSERT(args.length() == 1); | 8875 ASSERT(args.length() == 1); |
9100 CONVERT_CHECKED(JSObject, object, args[0]); | 8876 CONVERT_CHECKED(JSObject, object, args[0]); |
9101 HeapObject* elements = object->elements(); | 8877 HeapObject* elements = object->elements(); |
9102 if (elements->IsDictionary()) { | 8878 if (elements->IsDictionary()) { |
9103 return Smi::FromInt(NumberDictionary::cast(elements)->NumberOfElements()); | 8879 return Smi::FromInt(NumberDictionary::cast(elements)->NumberOfElements()); |
9104 } else if (object->IsJSArray()) { | 8880 } else if (object->IsJSArray()) { |
9105 return JSArray::cast(object)->length(); | 8881 return JSArray::cast(object)->length(); |
9106 } else { | 8882 } else { |
9107 return Smi::FromInt(FixedArray::cast(elements)->length()); | 8883 return Smi::FromInt(FixedArray::cast(elements)->length()); |
9108 } | 8884 } |
9109 } | 8885 } |
9110 | 8886 |
9111 | 8887 |
9112 static MaybeObject* Runtime_SwapElements(RUNTIME_CALLING_CONVENTION) { | 8888 RUNTIME_FUNCTION(MaybeObject*, Runtime_SwapElements) { |
9113 RUNTIME_GET_ISOLATE; | |
9114 HandleScope handle_scope(isolate); | 8889 HandleScope handle_scope(isolate); |
9115 | 8890 |
9116 ASSERT_EQ(3, args.length()); | 8891 ASSERT_EQ(3, args.length()); |
9117 | 8892 |
9118 CONVERT_ARG_CHECKED(JSObject, object, 0); | 8893 CONVERT_ARG_CHECKED(JSObject, object, 0); |
9119 Handle<Object> key1 = args.at<Object>(1); | 8894 Handle<Object> key1 = args.at<Object>(1); |
9120 Handle<Object> key2 = args.at<Object>(2); | 8895 Handle<Object> key2 = args.at<Object>(2); |
9121 | 8896 |
9122 uint32_t index1, index2; | 8897 uint32_t index1, index2; |
9123 if (!key1->ToArrayIndex(&index1) | 8898 if (!key1->ToArrayIndex(&index1) |
(...skipping 14 matching lines...) Expand all Loading... |
9138 | 8913 |
9139 return isolate->heap()->undefined_value(); | 8914 return isolate->heap()->undefined_value(); |
9140 } | 8915 } |
9141 | 8916 |
9142 | 8917 |
9143 // Returns an array that tells you where in the [0, length) interval an array | 8918 // Returns an array that tells you where in the [0, length) interval an array |
9144 // might have elements. Can either return keys (positive integers) or | 8919 // might have elements. Can either return keys (positive integers) or |
9145 // intervals (pair of a negative integer (-start-1) followed by a | 8920 // intervals (pair of a negative integer (-start-1) followed by a |
9146 // positive (length)) or undefined values. | 8921 // positive (length)) or undefined values. |
9147 // Intervals can span over some keys that are not in the object. | 8922 // Intervals can span over some keys that are not in the object. |
9148 static MaybeObject* Runtime_GetArrayKeys(RUNTIME_CALLING_CONVENTION) { | 8923 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { |
9149 RUNTIME_GET_ISOLATE; | |
9150 ASSERT(args.length() == 2); | 8924 ASSERT(args.length() == 2); |
9151 HandleScope scope(isolate); | 8925 HandleScope scope(isolate); |
9152 CONVERT_ARG_CHECKED(JSObject, array, 0); | 8926 CONVERT_ARG_CHECKED(JSObject, array, 0); |
9153 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 8927 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
9154 if (array->elements()->IsDictionary()) { | 8928 if (array->elements()->IsDictionary()) { |
9155 // Create an array and get all the keys into it, then remove all the | 8929 // Create an array and get all the keys into it, then remove all the |
9156 // keys that are not integers in the range 0 to length-1. | 8930 // keys that are not integers in the range 0 to length-1. |
9157 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); | 8931 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); |
9158 int keys_length = keys->length(); | 8932 int keys_length = keys->length(); |
9159 for (int i = 0; i < keys_length; i++) { | 8933 for (int i = 0; i < keys_length; i++) { |
(...skipping 19 matching lines...) Expand all Loading... |
9179 return *isolate->factory()->NewJSArrayWithElements(single_interval); | 8953 return *isolate->factory()->NewJSArrayWithElements(single_interval); |
9180 } | 8954 } |
9181 } | 8955 } |
9182 | 8956 |
9183 | 8957 |
9184 // DefineAccessor takes an optional final argument which is the | 8958 // DefineAccessor takes an optional final argument which is the |
9185 // property attributes (eg, DONT_ENUM, DONT_DELETE). IMPORTANT: due | 8959 // property attributes (eg, DONT_ENUM, DONT_DELETE). IMPORTANT: due |
9186 // to the way accessors are implemented, it is set for both the getter | 8960 // to the way accessors are implemented, it is set for both the getter |
9187 // and setter on the first call to DefineAccessor and ignored on | 8961 // and setter on the first call to DefineAccessor and ignored on |
9188 // subsequent calls. | 8962 // subsequent calls. |
9189 static MaybeObject* Runtime_DefineAccessor(RUNTIME_CALLING_CONVENTION) { | 8963 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineAccessor) { |
9190 RUNTIME_GET_ISOLATE; | |
9191 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 8964 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
9192 // Compute attributes. | 8965 // Compute attributes. |
9193 PropertyAttributes attributes = NONE; | 8966 PropertyAttributes attributes = NONE; |
9194 if (args.length() == 5) { | 8967 if (args.length() == 5) { |
9195 CONVERT_CHECKED(Smi, attrs, args[4]); | 8968 CONVERT_CHECKED(Smi, attrs, args[4]); |
9196 int value = attrs->value(); | 8969 int value = attrs->value(); |
9197 // Only attribute bits should be set. | 8970 // Only attribute bits should be set. |
9198 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 8971 ASSERT((value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
9199 attributes = static_cast<PropertyAttributes>(value); | 8972 attributes = static_cast<PropertyAttributes>(value); |
9200 } | 8973 } |
9201 | 8974 |
9202 CONVERT_CHECKED(JSObject, obj, args[0]); | 8975 CONVERT_CHECKED(JSObject, obj, args[0]); |
9203 CONVERT_CHECKED(String, name, args[1]); | 8976 CONVERT_CHECKED(String, name, args[1]); |
9204 CONVERT_CHECKED(Smi, flag, args[2]); | 8977 CONVERT_CHECKED(Smi, flag, args[2]); |
9205 CONVERT_CHECKED(JSFunction, fun, args[3]); | 8978 CONVERT_CHECKED(JSFunction, fun, args[3]); |
9206 return obj->DefineAccessor(name, flag->value() == 0, fun, attributes); | 8979 return obj->DefineAccessor(name, flag->value() == 0, fun, attributes); |
9207 } | 8980 } |
9208 | 8981 |
9209 | 8982 |
9210 static MaybeObject* Runtime_LookupAccessor(RUNTIME_CALLING_CONVENTION) { | 8983 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { |
9211 RUNTIME_GET_ISOLATE; | |
9212 ASSERT(args.length() == 3); | 8984 ASSERT(args.length() == 3); |
9213 CONVERT_CHECKED(JSObject, obj, args[0]); | 8985 CONVERT_CHECKED(JSObject, obj, args[0]); |
9214 CONVERT_CHECKED(String, name, args[1]); | 8986 CONVERT_CHECKED(String, name, args[1]); |
9215 CONVERT_CHECKED(Smi, flag, args[2]); | 8987 CONVERT_CHECKED(Smi, flag, args[2]); |
9216 return obj->LookupAccessor(name, flag->value() == 0); | 8988 return obj->LookupAccessor(name, flag->value() == 0); |
9217 } | 8989 } |
9218 | 8990 |
9219 | 8991 |
9220 #ifdef ENABLE_DEBUGGER_SUPPORT | 8992 #ifdef ENABLE_DEBUGGER_SUPPORT |
9221 static MaybeObject* Runtime_DebugBreak(RUNTIME_CALLING_CONVENTION) { | 8993 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { |
9222 RUNTIME_GET_ISOLATE; | |
9223 ASSERT(args.length() == 0); | 8994 ASSERT(args.length() == 0); |
9224 return Execution::DebugBreakHelper(); | 8995 return Execution::DebugBreakHelper(); |
9225 } | 8996 } |
9226 | 8997 |
9227 | 8998 |
9228 // Helper functions for wrapping and unwrapping stack frame ids. | 8999 // Helper functions for wrapping and unwrapping stack frame ids. |
9229 static Smi* WrapFrameId(StackFrame::Id id) { | 9000 static Smi* WrapFrameId(StackFrame::Id id) { |
9230 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 9001 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
9231 return Smi::FromInt(id >> 2); | 9002 return Smi::FromInt(id >> 2); |
9232 } | 9003 } |
9233 | 9004 |
9234 | 9005 |
9235 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { | 9006 static StackFrame::Id UnwrapFrameId(Smi* wrapped) { |
9236 return static_cast<StackFrame::Id>(wrapped->value() << 2); | 9007 return static_cast<StackFrame::Id>(wrapped->value() << 2); |
9237 } | 9008 } |
9238 | 9009 |
9239 | 9010 |
9240 // Adds a JavaScript function as a debug event listener. | 9011 // Adds a JavaScript function as a debug event listener. |
9241 // args[0]: debug event listener function to set or null or undefined for | 9012 // args[0]: debug event listener function to set or null or undefined for |
9242 // clearing the event listener function | 9013 // clearing the event listener function |
9243 // args[1]: object supplied during callback | 9014 // args[1]: object supplied during callback |
9244 static MaybeObject* Runtime_SetDebugEventListener(RUNTIME_CALLING_CONVENTION) { | 9015 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { |
9245 RUNTIME_GET_ISOLATE; | |
9246 ASSERT(args.length() == 2); | 9016 ASSERT(args.length() == 2); |
9247 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 9017 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
9248 args[0]->IsUndefined() || | 9018 args[0]->IsUndefined() || |
9249 args[0]->IsNull()); | 9019 args[0]->IsNull()); |
9250 Handle<Object> callback = args.at<Object>(0); | 9020 Handle<Object> callback = args.at<Object>(0); |
9251 Handle<Object> data = args.at<Object>(1); | 9021 Handle<Object> data = args.at<Object>(1); |
9252 isolate->debugger()->SetEventListener(callback, data); | 9022 isolate->debugger()->SetEventListener(callback, data); |
9253 | 9023 |
9254 return isolate->heap()->undefined_value(); | 9024 return isolate->heap()->undefined_value(); |
9255 } | 9025 } |
9256 | 9026 |
9257 | 9027 |
9258 static MaybeObject* Runtime_Break(RUNTIME_CALLING_CONVENTION) { | 9028 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { |
9259 RUNTIME_GET_ISOLATE; | |
9260 ASSERT(args.length() == 0); | 9029 ASSERT(args.length() == 0); |
9261 isolate->stack_guard()->DebugBreak(); | 9030 isolate->stack_guard()->DebugBreak(); |
9262 return isolate->heap()->undefined_value(); | 9031 return isolate->heap()->undefined_value(); |
9263 } | 9032 } |
9264 | 9033 |
9265 | 9034 |
9266 static MaybeObject* DebugLookupResultValue(Heap* heap, | 9035 static MaybeObject* DebugLookupResultValue(Heap* heap, |
9267 Object* receiver, | 9036 Object* receiver, |
9268 String* name, | 9037 String* name, |
9269 LookupResult* result, | 9038 LookupResult* result, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9325 // args[1]: name of the property | 9094 // args[1]: name of the property |
9326 // | 9095 // |
9327 // The array returned contains the following information: | 9096 // The array returned contains the following information: |
9328 // 0: Property value | 9097 // 0: Property value |
9329 // 1: Property details | 9098 // 1: Property details |
9330 // 2: Property value is exception | 9099 // 2: Property value is exception |
9331 // 3: Getter function if defined | 9100 // 3: Getter function if defined |
9332 // 4: Setter function if defined | 9101 // 4: Setter function if defined |
9333 // Items 2-4 are only filled if the property has either a getter or a setter | 9102 // Items 2-4 are only filled if the property has either a getter or a setter |
9334 // defined through __defineGetter__ and/or __defineSetter__. | 9103 // defined through __defineGetter__ and/or __defineSetter__. |
9335 static MaybeObject* Runtime_DebugGetPropertyDetails( | 9104 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { |
9336 RUNTIME_CALLING_CONVENTION) { | |
9337 RUNTIME_GET_ISOLATE; | |
9338 HandleScope scope(isolate); | 9105 HandleScope scope(isolate); |
9339 | 9106 |
9340 ASSERT(args.length() == 2); | 9107 ASSERT(args.length() == 2); |
9341 | 9108 |
9342 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 9109 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
9343 CONVERT_ARG_CHECKED(String, name, 1); | 9110 CONVERT_ARG_CHECKED(String, name, 1); |
9344 | 9111 |
9345 // Make sure to set the current context to the context before the debugger was | 9112 // Make sure to set the current context to the context before the debugger was |
9346 // entered (if the debugger is entered). The reason for switching context here | 9113 // entered (if the debugger is entered). The reason for switching context here |
9347 // is that for some property lookups (accessors and interceptors) callbacks | 9114 // is that for some property lookups (accessors and interceptors) callbacks |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9427 } | 9194 } |
9428 if (i < length - 1) { | 9195 if (i < length - 1) { |
9429 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 9196 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
9430 } | 9197 } |
9431 } | 9198 } |
9432 | 9199 |
9433 return isolate->heap()->undefined_value(); | 9200 return isolate->heap()->undefined_value(); |
9434 } | 9201 } |
9435 | 9202 |
9436 | 9203 |
9437 static MaybeObject* Runtime_DebugGetProperty(RUNTIME_CALLING_CONVENTION) { | 9204 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { |
9438 RUNTIME_GET_ISOLATE; | |
9439 HandleScope scope(isolate); | 9205 HandleScope scope(isolate); |
9440 | 9206 |
9441 ASSERT(args.length() == 2); | 9207 ASSERT(args.length() == 2); |
9442 | 9208 |
9443 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 9209 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
9444 CONVERT_ARG_CHECKED(String, name, 1); | 9210 CONVERT_ARG_CHECKED(String, name, 1); |
9445 | 9211 |
9446 LookupResult result; | 9212 LookupResult result; |
9447 obj->Lookup(*name, &result); | 9213 obj->Lookup(*name, &result); |
9448 if (result.IsProperty()) { | 9214 if (result.IsProperty()) { |
9449 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); | 9215 return DebugLookupResultValue(isolate->heap(), *obj, *name, &result, NULL); |
9450 } | 9216 } |
9451 return isolate->heap()->undefined_value(); | 9217 return isolate->heap()->undefined_value(); |
9452 } | 9218 } |
9453 | 9219 |
9454 | 9220 |
9455 // Return the property type calculated from the property details. | 9221 // Return the property type calculated from the property details. |
9456 // args[0]: smi with property details. | 9222 // args[0]: smi with property details. |
9457 static MaybeObject* Runtime_DebugPropertyTypeFromDetails( | 9223 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { |
9458 RUNTIME_CALLING_CONVENTION) { | |
9459 RUNTIME_GET_ISOLATE; | |
9460 ASSERT(args.length() == 1); | 9224 ASSERT(args.length() == 1); |
9461 CONVERT_CHECKED(Smi, details, args[0]); | 9225 CONVERT_CHECKED(Smi, details, args[0]); |
9462 PropertyType type = PropertyDetails(details).type(); | 9226 PropertyType type = PropertyDetails(details).type(); |
9463 return Smi::FromInt(static_cast<int>(type)); | 9227 return Smi::FromInt(static_cast<int>(type)); |
9464 } | 9228 } |
9465 | 9229 |
9466 | 9230 |
9467 // Return the property attribute calculated from the property details. | 9231 // Return the property attribute calculated from the property details. |
9468 // args[0]: smi with property details. | 9232 // args[0]: smi with property details. |
9469 static MaybeObject* Runtime_DebugPropertyAttributesFromDetails( | 9233 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { |
9470 RUNTIME_CALLING_CONVENTION) { | |
9471 RUNTIME_GET_ISOLATE; | |
9472 ASSERT(args.length() == 1); | 9234 ASSERT(args.length() == 1); |
9473 CONVERT_CHECKED(Smi, details, args[0]); | 9235 CONVERT_CHECKED(Smi, details, args[0]); |
9474 PropertyAttributes attributes = PropertyDetails(details).attributes(); | 9236 PropertyAttributes attributes = PropertyDetails(details).attributes(); |
9475 return Smi::FromInt(static_cast<int>(attributes)); | 9237 return Smi::FromInt(static_cast<int>(attributes)); |
9476 } | 9238 } |
9477 | 9239 |
9478 | 9240 |
9479 // Return the property insertion index calculated from the property details. | 9241 // Return the property insertion index calculated from the property details. |
9480 // args[0]: smi with property details. | 9242 // args[0]: smi with property details. |
9481 static MaybeObject* Runtime_DebugPropertyIndexFromDetails( | 9243 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { |
9482 RUNTIME_CALLING_CONVENTION) { | |
9483 RUNTIME_GET_ISOLATE; | |
9484 ASSERT(args.length() == 1); | 9244 ASSERT(args.length() == 1); |
9485 CONVERT_CHECKED(Smi, details, args[0]); | 9245 CONVERT_CHECKED(Smi, details, args[0]); |
9486 int index = PropertyDetails(details).index(); | 9246 int index = PropertyDetails(details).index(); |
9487 return Smi::FromInt(index); | 9247 return Smi::FromInt(index); |
9488 } | 9248 } |
9489 | 9249 |
9490 | 9250 |
9491 // Return property value from named interceptor. | 9251 // Return property value from named interceptor. |
9492 // args[0]: object | 9252 // args[0]: object |
9493 // args[1]: property name | 9253 // args[1]: property name |
9494 static MaybeObject* Runtime_DebugNamedInterceptorPropertyValue( | 9254 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { |
9495 RUNTIME_CALLING_CONVENTION) { | |
9496 RUNTIME_GET_ISOLATE; | |
9497 HandleScope scope(isolate); | 9255 HandleScope scope(isolate); |
9498 ASSERT(args.length() == 2); | 9256 ASSERT(args.length() == 2); |
9499 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 9257 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
9500 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | 9258 RUNTIME_ASSERT(obj->HasNamedInterceptor()); |
9501 CONVERT_ARG_CHECKED(String, name, 1); | 9259 CONVERT_ARG_CHECKED(String, name, 1); |
9502 | 9260 |
9503 PropertyAttributes attributes; | 9261 PropertyAttributes attributes; |
9504 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes); | 9262 return obj->GetPropertyWithInterceptor(*obj, *name, &attributes); |
9505 } | 9263 } |
9506 | 9264 |
9507 | 9265 |
9508 // Return element value from indexed interceptor. | 9266 // Return element value from indexed interceptor. |
9509 // args[0]: object | 9267 // args[0]: object |
9510 // args[1]: index | 9268 // args[1]: index |
9511 static MaybeObject* Runtime_DebugIndexedInterceptorElementValue( | 9269 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { |
9512 RUNTIME_CALLING_CONVENTION) { | |
9513 RUNTIME_GET_ISOLATE; | |
9514 HandleScope scope(isolate); | 9270 HandleScope scope(isolate); |
9515 ASSERT(args.length() == 2); | 9271 ASSERT(args.length() == 2); |
9516 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 9272 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
9517 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 9273 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
9518 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 9274 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
9519 | 9275 |
9520 return obj->GetElementWithInterceptor(*obj, index); | 9276 return obj->GetElementWithInterceptor(*obj, index); |
9521 } | 9277 } |
9522 | 9278 |
9523 | 9279 |
9524 static MaybeObject* Runtime_CheckExecutionState(RUNTIME_CALLING_CONVENTION) { | 9280 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { |
9525 RUNTIME_GET_ISOLATE; | |
9526 ASSERT(args.length() >= 1); | 9281 ASSERT(args.length() >= 1); |
9527 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 9282 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
9528 // Check that the break id is valid. | 9283 // Check that the break id is valid. |
9529 if (isolate->debug()->break_id() == 0 || | 9284 if (isolate->debug()->break_id() == 0 || |
9530 break_id != isolate->debug()->break_id()) { | 9285 break_id != isolate->debug()->break_id()) { |
9531 return isolate->Throw( | 9286 return isolate->Throw( |
9532 isolate->heap()->illegal_execution_state_symbol()); | 9287 isolate->heap()->illegal_execution_state_symbol()); |
9533 } | 9288 } |
9534 | 9289 |
9535 return isolate->heap()->true_value(); | 9290 return isolate->heap()->true_value(); |
9536 } | 9291 } |
9537 | 9292 |
9538 | 9293 |
9539 static MaybeObject* Runtime_GetFrameCount(RUNTIME_CALLING_CONVENTION) { | 9294 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) { |
9540 RUNTIME_GET_ISOLATE; | |
9541 HandleScope scope(isolate); | 9295 HandleScope scope(isolate); |
9542 ASSERT(args.length() == 1); | 9296 ASSERT(args.length() == 1); |
9543 | 9297 |
9544 // Check arguments. | 9298 // Check arguments. |
9545 Object* result; | 9299 Object* result; |
9546 { MaybeObject* maybe_result = Runtime_CheckExecutionState(args, isolate); | 9300 { MaybeObject* maybe_result = Runtime_CheckExecutionState( |
| 9301 RUNTIME_ARGUMENTS(isolate, args)); |
9547 if (!maybe_result->ToObject(&result)) return maybe_result; | 9302 if (!maybe_result->ToObject(&result)) return maybe_result; |
9548 } | 9303 } |
9549 | 9304 |
9550 // Count all frames which are relevant to debugging stack trace. | 9305 // Count all frames which are relevant to debugging stack trace. |
9551 int n = 0; | 9306 int n = 0; |
9552 StackFrame::Id id = isolate->debug()->break_frame_id(); | 9307 StackFrame::Id id = isolate->debug()->break_frame_id(); |
9553 if (id == StackFrame::NO_ID) { | 9308 if (id == StackFrame::NO_ID) { |
9554 // If there is no JavaScript stack frame count is 0. | 9309 // If there is no JavaScript stack frame count is 0. |
9555 return Smi::FromInt(0); | 9310 return Smi::FromInt(0); |
9556 } | 9311 } |
(...skipping 23 matching lines...) Expand all Loading... |
9580 // 2: Function | 9335 // 2: Function |
9581 // 3: Argument count | 9336 // 3: Argument count |
9582 // 4: Local count | 9337 // 4: Local count |
9583 // 5: Source position | 9338 // 5: Source position |
9584 // 6: Constructor call | 9339 // 6: Constructor call |
9585 // 7: Is at return | 9340 // 7: Is at return |
9586 // 8: Debugger frame | 9341 // 8: Debugger frame |
9587 // Arguments name, value | 9342 // Arguments name, value |
9588 // Locals name, value | 9343 // Locals name, value |
9589 // Return value if any | 9344 // Return value if any |
9590 static MaybeObject* Runtime_GetFrameDetails(RUNTIME_CALLING_CONVENTION) { | 9345 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { |
9591 RUNTIME_GET_ISOLATE; | |
9592 HandleScope scope(isolate); | 9346 HandleScope scope(isolate); |
9593 ASSERT(args.length() == 2); | 9347 ASSERT(args.length() == 2); |
9594 | 9348 |
9595 // Check arguments. | 9349 // Check arguments. |
9596 Object* check; | 9350 Object* check; |
9597 { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate); | 9351 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 9352 RUNTIME_ARGUMENTS(isolate, args)); |
9598 if (!maybe_check->ToObject(&check)) return maybe_check; | 9353 if (!maybe_check->ToObject(&check)) return maybe_check; |
9599 } | 9354 } |
9600 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 9355 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
9601 Heap* heap = isolate->heap(); | 9356 Heap* heap = isolate->heap(); |
9602 | 9357 |
9603 // Find the relevant frame with the requested index. | 9358 // Find the relevant frame with the requested index. |
9604 StackFrame::Id id = isolate->debug()->break_frame_id(); | 9359 StackFrame::Id id = isolate->debug()->break_frame_id(); |
9605 if (id == StackFrame::NO_ID) { | 9360 if (id == StackFrame::NO_ID) { |
9606 // If there are no JavaScript stack frames return undefined. | 9361 // If there are no JavaScript stack frames return undefined. |
9607 return heap->undefined_value(); | 9362 return heap->undefined_value(); |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10204 JavaScriptFrame* frame_; | 9959 JavaScriptFrame* frame_; |
10205 Handle<JSFunction> function_; | 9960 Handle<JSFunction> function_; |
10206 Handle<Context> context_; | 9961 Handle<Context> context_; |
10207 bool local_done_; | 9962 bool local_done_; |
10208 bool at_local_; | 9963 bool at_local_; |
10209 | 9964 |
10210 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 9965 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
10211 }; | 9966 }; |
10212 | 9967 |
10213 | 9968 |
10214 static MaybeObject* Runtime_GetScopeCount(RUNTIME_CALLING_CONVENTION) { | 9969 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { |
10215 RUNTIME_GET_ISOLATE; | |
10216 HandleScope scope(isolate); | 9970 HandleScope scope(isolate); |
10217 ASSERT(args.length() == 2); | 9971 ASSERT(args.length() == 2); |
10218 | 9972 |
10219 // Check arguments. | 9973 // Check arguments. |
10220 Object* check; | 9974 Object* check; |
10221 { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate); | 9975 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 9976 RUNTIME_ARGUMENTS(isolate, args)); |
10222 if (!maybe_check->ToObject(&check)) return maybe_check; | 9977 if (!maybe_check->ToObject(&check)) return maybe_check; |
10223 } | 9978 } |
10224 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 9979 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
10225 | 9980 |
10226 // Get the frame where the debugging is performed. | 9981 // Get the frame where the debugging is performed. |
10227 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 9982 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
10228 JavaScriptFrameIterator it(id); | 9983 JavaScriptFrameIterator it(id); |
10229 JavaScriptFrame* frame = it.frame(); | 9984 JavaScriptFrame* frame = it.frame(); |
10230 | 9985 |
10231 // Count the visible scopes. | 9986 // Count the visible scopes. |
(...skipping 11 matching lines...) Expand all Loading... |
10243 static const int kScopeDetailsSize = 2; | 9998 static const int kScopeDetailsSize = 2; |
10244 | 9999 |
10245 // Return an array with scope details | 10000 // Return an array with scope details |
10246 // args[0]: number: break id | 10001 // args[0]: number: break id |
10247 // args[1]: number: frame index | 10002 // args[1]: number: frame index |
10248 // args[2]: number: scope index | 10003 // args[2]: number: scope index |
10249 // | 10004 // |
10250 // The array returned contains the following information: | 10005 // The array returned contains the following information: |
10251 // 0: Scope type | 10006 // 0: Scope type |
10252 // 1: Scope object | 10007 // 1: Scope object |
10253 static MaybeObject* Runtime_GetScopeDetails(RUNTIME_CALLING_CONVENTION) { | 10008 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { |
10254 RUNTIME_GET_ISOLATE; | |
10255 HandleScope scope(isolate); | 10009 HandleScope scope(isolate); |
10256 ASSERT(args.length() == 3); | 10010 ASSERT(args.length() == 3); |
10257 | 10011 |
10258 // Check arguments. | 10012 // Check arguments. |
10259 Object* check; | 10013 Object* check; |
10260 { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate); | 10014 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 10015 RUNTIME_ARGUMENTS(isolate, args)); |
10261 if (!maybe_check->ToObject(&check)) return maybe_check; | 10016 if (!maybe_check->ToObject(&check)) return maybe_check; |
10262 } | 10017 } |
10263 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10018 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
10264 CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]); | 10019 CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]); |
10265 | 10020 |
10266 // Get the frame where the debugging is performed. | 10021 // Get the frame where the debugging is performed. |
10267 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 10022 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
10268 JavaScriptFrameIterator frame_it(id); | 10023 JavaScriptFrameIterator frame_it(id); |
10269 JavaScriptFrame* frame = frame_it.frame(); | 10024 JavaScriptFrame* frame = frame_it.frame(); |
10270 | 10025 |
(...skipping 14 matching lines...) Expand all Loading... |
10285 // Fill in scope details. | 10040 // Fill in scope details. |
10286 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); | 10041 details->set(kScopeDetailsTypeIndex, Smi::FromInt(it.Type())); |
10287 Handle<JSObject> scope_object = it.ScopeObject(); | 10042 Handle<JSObject> scope_object = it.ScopeObject(); |
10288 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); | 10043 RETURN_IF_EMPTY_HANDLE(isolate, scope_object); |
10289 details->set(kScopeDetailsObjectIndex, *scope_object); | 10044 details->set(kScopeDetailsObjectIndex, *scope_object); |
10290 | 10045 |
10291 return *isolate->factory()->NewJSArrayWithElements(details); | 10046 return *isolate->factory()->NewJSArrayWithElements(details); |
10292 } | 10047 } |
10293 | 10048 |
10294 | 10049 |
10295 static MaybeObject* Runtime_DebugPrintScopes(RUNTIME_CALLING_CONVENTION) { | 10050 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { |
10296 RUNTIME_GET_ISOLATE; | |
10297 HandleScope scope(isolate); | 10051 HandleScope scope(isolate); |
10298 ASSERT(args.length() == 0); | 10052 ASSERT(args.length() == 0); |
10299 | 10053 |
10300 #ifdef DEBUG | 10054 #ifdef DEBUG |
10301 // Print the scopes for the top frame. | 10055 // Print the scopes for the top frame. |
10302 StackFrameLocator locator; | 10056 StackFrameLocator locator; |
10303 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 10057 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
10304 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { | 10058 for (ScopeIterator it(isolate, frame); !it.Done(); it.Next()) { |
10305 it.DebugPrint(); | 10059 it.DebugPrint(); |
10306 } | 10060 } |
10307 #endif | 10061 #endif |
10308 return isolate->heap()->undefined_value(); | 10062 return isolate->heap()->undefined_value(); |
10309 } | 10063 } |
10310 | 10064 |
10311 | 10065 |
10312 static MaybeObject* Runtime_GetThreadCount(RUNTIME_CALLING_CONVENTION) { | 10066 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { |
10313 RUNTIME_GET_ISOLATE; | |
10314 HandleScope scope(isolate); | 10067 HandleScope scope(isolate); |
10315 ASSERT(args.length() == 1); | 10068 ASSERT(args.length() == 1); |
10316 | 10069 |
10317 // Check arguments. | 10070 // Check arguments. |
10318 Object* result; | 10071 Object* result; |
10319 { MaybeObject* maybe_result = Runtime_CheckExecutionState(args, isolate); | 10072 { MaybeObject* maybe_result = Runtime_CheckExecutionState( |
| 10073 RUNTIME_ARGUMENTS(isolate, args)); |
10320 if (!maybe_result->ToObject(&result)) return maybe_result; | 10074 if (!maybe_result->ToObject(&result)) return maybe_result; |
10321 } | 10075 } |
10322 | 10076 |
10323 // Count all archived V8 threads. | 10077 // Count all archived V8 threads. |
10324 int n = 0; | 10078 int n = 0; |
10325 for (ThreadState* thread = | 10079 for (ThreadState* thread = |
10326 isolate->thread_manager()->FirstThreadStateInUse(); | 10080 isolate->thread_manager()->FirstThreadStateInUse(); |
10327 thread != NULL; | 10081 thread != NULL; |
10328 thread = thread->Next()) { | 10082 thread = thread->Next()) { |
10329 n++; | 10083 n++; |
10330 } | 10084 } |
10331 | 10085 |
10332 // Total number of threads is current thread and archived threads. | 10086 // Total number of threads is current thread and archived threads. |
10333 return Smi::FromInt(n + 1); | 10087 return Smi::FromInt(n + 1); |
10334 } | 10088 } |
10335 | 10089 |
10336 | 10090 |
10337 static const int kThreadDetailsCurrentThreadIndex = 0; | 10091 static const int kThreadDetailsCurrentThreadIndex = 0; |
10338 static const int kThreadDetailsThreadIdIndex = 1; | 10092 static const int kThreadDetailsThreadIdIndex = 1; |
10339 static const int kThreadDetailsSize = 2; | 10093 static const int kThreadDetailsSize = 2; |
10340 | 10094 |
10341 // Return an array with thread details | 10095 // Return an array with thread details |
10342 // args[0]: number: break id | 10096 // args[0]: number: break id |
10343 // args[1]: number: thread index | 10097 // args[1]: number: thread index |
10344 // | 10098 // |
10345 // The array returned contains the following information: | 10099 // The array returned contains the following information: |
10346 // 0: Is current thread? | 10100 // 0: Is current thread? |
10347 // 1: Thread id | 10101 // 1: Thread id |
10348 static MaybeObject* Runtime_GetThreadDetails(RUNTIME_CALLING_CONVENTION) { | 10102 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadDetails) { |
10349 RUNTIME_GET_ISOLATE; | |
10350 HandleScope scope(isolate); | 10103 HandleScope scope(isolate); |
10351 ASSERT(args.length() == 2); | 10104 ASSERT(args.length() == 2); |
10352 | 10105 |
10353 // Check arguments. | 10106 // Check arguments. |
10354 Object* check; | 10107 Object* check; |
10355 { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate); | 10108 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 10109 RUNTIME_ARGUMENTS(isolate, args)); |
10356 if (!maybe_check->ToObject(&check)) return maybe_check; | 10110 if (!maybe_check->ToObject(&check)) return maybe_check; |
10357 } | 10111 } |
10358 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 10112 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
10359 | 10113 |
10360 // Allocate array for result. | 10114 // Allocate array for result. |
10361 Handle<FixedArray> details = | 10115 Handle<FixedArray> details = |
10362 isolate->factory()->NewFixedArray(kThreadDetailsSize); | 10116 isolate->factory()->NewFixedArray(kThreadDetailsSize); |
10363 | 10117 |
10364 // Thread index 0 is current thread. | 10118 // Thread index 0 is current thread. |
10365 if (index == 0) { | 10119 if (index == 0) { |
(...skipping 22 matching lines...) Expand all Loading... |
10388 details->set(kThreadDetailsThreadIdIndex, Smi::FromInt(thread->id())); | 10142 details->set(kThreadDetailsThreadIdIndex, Smi::FromInt(thread->id())); |
10389 } | 10143 } |
10390 | 10144 |
10391 // Convert to JS array and return. | 10145 // Convert to JS array and return. |
10392 return *isolate->factory()->NewJSArrayWithElements(details); | 10146 return *isolate->factory()->NewJSArrayWithElements(details); |
10393 } | 10147 } |
10394 | 10148 |
10395 | 10149 |
10396 // Sets the disable break state | 10150 // Sets the disable break state |
10397 // args[0]: disable break state | 10151 // args[0]: disable break state |
10398 static MaybeObject* Runtime_SetDisableBreak(RUNTIME_CALLING_CONVENTION) { | 10152 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { |
10399 RUNTIME_GET_ISOLATE; | |
10400 HandleScope scope(isolate); | 10153 HandleScope scope(isolate); |
10401 ASSERT(args.length() == 1); | 10154 ASSERT(args.length() == 1); |
10402 CONVERT_BOOLEAN_CHECKED(disable_break, args[0]); | 10155 CONVERT_BOOLEAN_CHECKED(disable_break, args[0]); |
10403 isolate->debug()->set_disable_break(disable_break); | 10156 isolate->debug()->set_disable_break(disable_break); |
10404 return isolate->heap()->undefined_value(); | 10157 return isolate->heap()->undefined_value(); |
10405 } | 10158 } |
10406 | 10159 |
10407 | 10160 |
10408 static MaybeObject* Runtime_GetBreakLocations(RUNTIME_CALLING_CONVENTION) { | 10161 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { |
10409 RUNTIME_GET_ISOLATE; | |
10410 HandleScope scope(isolate); | 10162 HandleScope scope(isolate); |
10411 ASSERT(args.length() == 1); | 10163 ASSERT(args.length() == 1); |
10412 | 10164 |
10413 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 10165 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
10414 Handle<SharedFunctionInfo> shared(fun->shared()); | 10166 Handle<SharedFunctionInfo> shared(fun->shared()); |
10415 // Find the number of break points | 10167 // Find the number of break points |
10416 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); | 10168 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); |
10417 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); | 10169 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); |
10418 // Return array as JS array | 10170 // Return array as JS array |
10419 return *isolate->factory()->NewJSArrayWithElements( | 10171 return *isolate->factory()->NewJSArrayWithElements( |
10420 Handle<FixedArray>::cast(break_locations)); | 10172 Handle<FixedArray>::cast(break_locations)); |
10421 } | 10173 } |
10422 | 10174 |
10423 | 10175 |
10424 // Set a break point in a function | 10176 // Set a break point in a function |
10425 // args[0]: function | 10177 // args[0]: function |
10426 // args[1]: number: break source position (within the function source) | 10178 // args[1]: number: break source position (within the function source) |
10427 // args[2]: number: break point object | 10179 // args[2]: number: break point object |
10428 static MaybeObject* Runtime_SetFunctionBreakPoint(RUNTIME_CALLING_CONVENTION) { | 10180 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { |
10429 RUNTIME_GET_ISOLATE; | |
10430 HandleScope scope(isolate); | 10181 HandleScope scope(isolate); |
10431 ASSERT(args.length() == 3); | 10182 ASSERT(args.length() == 3); |
10432 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 10183 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
10433 Handle<SharedFunctionInfo> shared(fun->shared()); | 10184 Handle<SharedFunctionInfo> shared(fun->shared()); |
10434 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 10185 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
10435 RUNTIME_ASSERT(source_position >= 0); | 10186 RUNTIME_ASSERT(source_position >= 0); |
10436 Handle<Object> break_point_object_arg = args.at<Object>(2); | 10187 Handle<Object> break_point_object_arg = args.at<Object>(2); |
10437 | 10188 |
10438 // Set break point. | 10189 // Set break point. |
10439 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, | 10190 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10520 return *target; | 10271 return *target; |
10521 } | 10272 } |
10522 | 10273 |
10523 | 10274 |
10524 // Changes the state of a break point in a script and returns source position | 10275 // Changes the state of a break point in a script and returns source position |
10525 // where break point was set. NOTE: Regarding performance see the NOTE for | 10276 // where break point was set. NOTE: Regarding performance see the NOTE for |
10526 // GetScriptFromScriptData. | 10277 // GetScriptFromScriptData. |
10527 // args[0]: script to set break point in | 10278 // args[0]: script to set break point in |
10528 // args[1]: number: break source position (within the script source) | 10279 // args[1]: number: break source position (within the script source) |
10529 // args[2]: number: break point object | 10280 // args[2]: number: break point object |
10530 static MaybeObject* Runtime_SetScriptBreakPoint(RUNTIME_CALLING_CONVENTION) { | 10281 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { |
10531 RUNTIME_GET_ISOLATE; | |
10532 HandleScope scope(isolate); | 10282 HandleScope scope(isolate); |
10533 ASSERT(args.length() == 3); | 10283 ASSERT(args.length() == 3); |
10534 CONVERT_ARG_CHECKED(JSValue, wrapper, 0); | 10284 CONVERT_ARG_CHECKED(JSValue, wrapper, 0); |
10535 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 10285 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
10536 RUNTIME_ASSERT(source_position >= 0); | 10286 RUNTIME_ASSERT(source_position >= 0); |
10537 Handle<Object> break_point_object_arg = args.at<Object>(2); | 10287 Handle<Object> break_point_object_arg = args.at<Object>(2); |
10538 | 10288 |
10539 // Get the script from the script wrapper. | 10289 // Get the script from the script wrapper. |
10540 RUNTIME_ASSERT(wrapper->value()->IsScript()); | 10290 RUNTIME_ASSERT(wrapper->value()->IsScript()); |
10541 Handle<Script> script(Script::cast(wrapper->value())); | 10291 Handle<Script> script(Script::cast(wrapper->value())); |
(...skipping 13 matching lines...) Expand all Loading... |
10555 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, &position); | 10305 isolate->debug()->SetBreakPoint(shared, break_point_object_arg, &position); |
10556 position += shared->start_position(); | 10306 position += shared->start_position(); |
10557 return Smi::FromInt(position); | 10307 return Smi::FromInt(position); |
10558 } | 10308 } |
10559 return isolate->heap()->undefined_value(); | 10309 return isolate->heap()->undefined_value(); |
10560 } | 10310 } |
10561 | 10311 |
10562 | 10312 |
10563 // Clear a break point | 10313 // Clear a break point |
10564 // args[0]: number: break point object | 10314 // args[0]: number: break point object |
10565 static MaybeObject* Runtime_ClearBreakPoint(RUNTIME_CALLING_CONVENTION) { | 10315 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { |
10566 RUNTIME_GET_ISOLATE; | |
10567 HandleScope scope(isolate); | 10316 HandleScope scope(isolate); |
10568 ASSERT(args.length() == 1); | 10317 ASSERT(args.length() == 1); |
10569 Handle<Object> break_point_object_arg = args.at<Object>(0); | 10318 Handle<Object> break_point_object_arg = args.at<Object>(0); |
10570 | 10319 |
10571 // Clear break point. | 10320 // Clear break point. |
10572 isolate->debug()->ClearBreakPoint(break_point_object_arg); | 10321 isolate->debug()->ClearBreakPoint(break_point_object_arg); |
10573 | 10322 |
10574 return isolate->heap()->undefined_value(); | 10323 return isolate->heap()->undefined_value(); |
10575 } | 10324 } |
10576 | 10325 |
10577 | 10326 |
10578 // Change the state of break on exceptions. | 10327 // Change the state of break on exceptions. |
10579 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. | 10328 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. |
10580 // args[1]: Boolean indicating on/off. | 10329 // args[1]: Boolean indicating on/off. |
10581 static MaybeObject* Runtime_ChangeBreakOnException(RUNTIME_CALLING_CONVENTION) { | 10330 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { |
10582 RUNTIME_GET_ISOLATE; | |
10583 HandleScope scope(isolate); | 10331 HandleScope scope(isolate); |
10584 ASSERT(args.length() == 2); | 10332 ASSERT(args.length() == 2); |
10585 RUNTIME_ASSERT(args[0]->IsNumber()); | 10333 RUNTIME_ASSERT(args[0]->IsNumber()); |
10586 CONVERT_BOOLEAN_CHECKED(enable, args[1]); | 10334 CONVERT_BOOLEAN_CHECKED(enable, args[1]); |
10587 | 10335 |
10588 // If the number doesn't match an enum value, the ChangeBreakOnException | 10336 // If the number doesn't match an enum value, the ChangeBreakOnException |
10589 // function will default to affecting caught exceptions. | 10337 // function will default to affecting caught exceptions. |
10590 ExceptionBreakType type = | 10338 ExceptionBreakType type = |
10591 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); | 10339 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); |
10592 // Update break point state. | 10340 // Update break point state. |
10593 isolate->debug()->ChangeBreakOnException(type, enable); | 10341 isolate->debug()->ChangeBreakOnException(type, enable); |
10594 return isolate->heap()->undefined_value(); | 10342 return isolate->heap()->undefined_value(); |
10595 } | 10343 } |
10596 | 10344 |
10597 | 10345 |
10598 // Returns the state of break on exceptions | 10346 // Returns the state of break on exceptions |
10599 // args[0]: boolean indicating uncaught exceptions | 10347 // args[0]: boolean indicating uncaught exceptions |
10600 static MaybeObject* Runtime_IsBreakOnException(RUNTIME_CALLING_CONVENTION) { | 10348 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsBreakOnException) { |
10601 RUNTIME_GET_ISOLATE; | |
10602 HandleScope scope(isolate); | 10349 HandleScope scope(isolate); |
10603 ASSERT(args.length() == 1); | 10350 ASSERT(args.length() == 1); |
10604 RUNTIME_ASSERT(args[0]->IsNumber()); | 10351 RUNTIME_ASSERT(args[0]->IsNumber()); |
10605 | 10352 |
10606 ExceptionBreakType type = | 10353 ExceptionBreakType type = |
10607 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); | 10354 static_cast<ExceptionBreakType>(NumberToUint32(args[0])); |
10608 bool result = isolate->debug()->IsBreakOnException(type); | 10355 bool result = isolate->debug()->IsBreakOnException(type); |
10609 return Smi::FromInt(result); | 10356 return Smi::FromInt(result); |
10610 } | 10357 } |
10611 | 10358 |
10612 | 10359 |
10613 // Prepare for stepping | 10360 // Prepare for stepping |
10614 // args[0]: break id for checking execution state | 10361 // args[0]: break id for checking execution state |
10615 // args[1]: step action from the enumeration StepAction | 10362 // args[1]: step action from the enumeration StepAction |
10616 // args[2]: number of times to perform the step, for step out it is the number | 10363 // args[2]: number of times to perform the step, for step out it is the number |
10617 // of frames to step down. | 10364 // of frames to step down. |
10618 static MaybeObject* Runtime_PrepareStep(RUNTIME_CALLING_CONVENTION) { | 10365 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) { |
10619 RUNTIME_GET_ISOLATE; | |
10620 HandleScope scope(isolate); | 10366 HandleScope scope(isolate); |
10621 ASSERT(args.length() == 3); | 10367 ASSERT(args.length() == 3); |
10622 // Check arguments. | 10368 // Check arguments. |
10623 Object* check; | 10369 Object* check; |
10624 { MaybeObject* maybe_check = Runtime_CheckExecutionState(args, isolate); | 10370 { MaybeObject* maybe_check = Runtime_CheckExecutionState( |
| 10371 RUNTIME_ARGUMENTS(isolate, args)); |
10625 if (!maybe_check->ToObject(&check)) return maybe_check; | 10372 if (!maybe_check->ToObject(&check)) return maybe_check; |
10626 } | 10373 } |
10627 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { | 10374 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { |
10628 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); | 10375 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); |
10629 } | 10376 } |
10630 | 10377 |
10631 // Get the step action and check validity. | 10378 // Get the step action and check validity. |
10632 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); | 10379 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); |
10633 if (step_action != StepIn && | 10380 if (step_action != StepIn && |
10634 step_action != StepNext && | 10381 step_action != StepNext && |
(...skipping 13 matching lines...) Expand all Loading... |
10648 isolate->debug()->ClearStepping(); | 10395 isolate->debug()->ClearStepping(); |
10649 | 10396 |
10650 // Prepare step. | 10397 // Prepare step. |
10651 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), | 10398 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), |
10652 step_count); | 10399 step_count); |
10653 return isolate->heap()->undefined_value(); | 10400 return isolate->heap()->undefined_value(); |
10654 } | 10401 } |
10655 | 10402 |
10656 | 10403 |
10657 // Clear all stepping set by PrepareStep. | 10404 // Clear all stepping set by PrepareStep. |
10658 static MaybeObject* Runtime_ClearStepping(RUNTIME_CALLING_CONVENTION) { | 10405 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { |
10659 RUNTIME_GET_ISOLATE; | |
10660 HandleScope scope(isolate); | 10406 HandleScope scope(isolate); |
10661 ASSERT(args.length() == 0); | 10407 ASSERT(args.length() == 0); |
10662 isolate->debug()->ClearStepping(); | 10408 isolate->debug()->ClearStepping(); |
10663 return isolate->heap()->undefined_value(); | 10409 return isolate->heap()->undefined_value(); |
10664 } | 10410 } |
10665 | 10411 |
10666 | 10412 |
10667 // Creates a copy of the with context chain. The copy of the context chain is | 10413 // Creates a copy of the with context chain. The copy of the context chain is |
10668 // is linked to the function context supplied. | 10414 // is linked to the function context supplied. |
10669 static Handle<Context> CopyWithContextChain(Handle<Context> context_chain, | 10415 static Handle<Context> CopyWithContextChain(Handle<Context> context_chain, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10732 // debugging. This is accomplished by creating a new context which in its | 10478 // debugging. This is accomplished by creating a new context which in its |
10733 // extension part has all the parameters and locals of the function on the | 10479 // extension part has all the parameters and locals of the function on the |
10734 // stack frame. A function which calls eval with the code to evaluate is then | 10480 // stack frame. A function which calls eval with the code to evaluate is then |
10735 // compiled in this context and called in this context. As this context | 10481 // compiled in this context and called in this context. As this context |
10736 // replaces the context of the function on the stack frame a new (empty) | 10482 // replaces the context of the function on the stack frame a new (empty) |
10737 // function is created as well to be used as the closure for the context. | 10483 // function is created as well to be used as the closure for the context. |
10738 // This function and the context acts as replacements for the function on the | 10484 // This function and the context acts as replacements for the function on the |
10739 // stack frame presenting the same view of the values of parameters and | 10485 // stack frame presenting the same view of the values of parameters and |
10740 // local variables as if the piece of JavaScript was evaluated at the point | 10486 // local variables as if the piece of JavaScript was evaluated at the point |
10741 // where the function on the stack frame is currently stopped. | 10487 // where the function on the stack frame is currently stopped. |
10742 static MaybeObject* Runtime_DebugEvaluate(RUNTIME_CALLING_CONVENTION) { | 10488 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { |
10743 RUNTIME_GET_ISOLATE; | |
10744 HandleScope scope(isolate); | 10489 HandleScope scope(isolate); |
10745 | 10490 |
10746 // Check the execution state and decode arguments frame and source to be | 10491 // Check the execution state and decode arguments frame and source to be |
10747 // evaluated. | 10492 // evaluated. |
10748 ASSERT(args.length() == 5); | 10493 ASSERT(args.length() == 5); |
10749 Object* check_result; | 10494 Object* check_result; |
10750 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args, | 10495 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
10751 isolate); | 10496 RUNTIME_ARGUMENTS(isolate, args)); |
10752 if (!maybe_check_result->ToObject(&check_result)) { | 10497 if (!maybe_check_result->ToObject(&check_result)) { |
10753 return maybe_check_result; | 10498 return maybe_check_result; |
10754 } | 10499 } |
10755 } | 10500 } |
10756 CONVERT_CHECKED(Smi, wrapped_id, args[1]); | 10501 CONVERT_CHECKED(Smi, wrapped_id, args[1]); |
10757 CONVERT_ARG_CHECKED(String, source, 2); | 10502 CONVERT_ARG_CHECKED(String, source, 2); |
10758 CONVERT_BOOLEAN_CHECKED(disable_break, args[3]); | 10503 CONVERT_BOOLEAN_CHECKED(disable_break, args[3]); |
10759 Handle<Object> additional_context(args[4]); | 10504 Handle<Object> additional_context(args[4]); |
10760 | 10505 |
10761 // Handle the processing of break. | 10506 // Handle the processing of break. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10860 // Skip the global proxy as it has no properties and always delegates to the | 10605 // Skip the global proxy as it has no properties and always delegates to the |
10861 // real global object. | 10606 // real global object. |
10862 if (result->IsJSGlobalProxy()) { | 10607 if (result->IsJSGlobalProxy()) { |
10863 result = Handle<JSObject>(JSObject::cast(result->GetPrototype())); | 10608 result = Handle<JSObject>(JSObject::cast(result->GetPrototype())); |
10864 } | 10609 } |
10865 | 10610 |
10866 return *result; | 10611 return *result; |
10867 } | 10612 } |
10868 | 10613 |
10869 | 10614 |
10870 static MaybeObject* Runtime_DebugEvaluateGlobal(RUNTIME_CALLING_CONVENTION) { | 10615 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { |
10871 RUNTIME_GET_ISOLATE; | |
10872 HandleScope scope(isolate); | 10616 HandleScope scope(isolate); |
10873 | 10617 |
10874 // Check the execution state and decode arguments frame and source to be | 10618 // Check the execution state and decode arguments frame and source to be |
10875 // evaluated. | 10619 // evaluated. |
10876 ASSERT(args.length() == 4); | 10620 ASSERT(args.length() == 4); |
10877 Object* check_result; | 10621 Object* check_result; |
10878 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args, | 10622 { MaybeObject* maybe_check_result = Runtime_CheckExecutionState( |
10879 isolate); | 10623 RUNTIME_ARGUMENTS(isolate, args)); |
10880 if (!maybe_check_result->ToObject(&check_result)) { | 10624 if (!maybe_check_result->ToObject(&check_result)) { |
10881 return maybe_check_result; | 10625 return maybe_check_result; |
10882 } | 10626 } |
10883 } | 10627 } |
10884 CONVERT_ARG_CHECKED(String, source, 1); | 10628 CONVERT_ARG_CHECKED(String, source, 1); |
10885 CONVERT_BOOLEAN_CHECKED(disable_break, args[2]); | 10629 CONVERT_BOOLEAN_CHECKED(disable_break, args[2]); |
10886 Handle<Object> additional_context(args[3]); | 10630 Handle<Object> additional_context(args[3]); |
10887 | 10631 |
10888 // Handle the processing of break. | 10632 // Handle the processing of break. |
10889 DisableBreak disable_break_save(disable_break); | 10633 DisableBreak disable_break_save(disable_break); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10932 bool has_pending_exception; | 10676 bool has_pending_exception; |
10933 Handle<Object> receiver = isolate->global(); | 10677 Handle<Object> receiver = isolate->global(); |
10934 Handle<Object> result = | 10678 Handle<Object> result = |
10935 Execution::Call(compiled_function, receiver, 0, NULL, | 10679 Execution::Call(compiled_function, receiver, 0, NULL, |
10936 &has_pending_exception); | 10680 &has_pending_exception); |
10937 if (has_pending_exception) return Failure::Exception(); | 10681 if (has_pending_exception) return Failure::Exception(); |
10938 return *result; | 10682 return *result; |
10939 } | 10683 } |
10940 | 10684 |
10941 | 10685 |
10942 static MaybeObject* Runtime_DebugGetLoadedScripts(RUNTIME_CALLING_CONVENTION) { | 10686 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetLoadedScripts) { |
10943 RUNTIME_GET_ISOLATE; | |
10944 HandleScope scope(isolate); | 10687 HandleScope scope(isolate); |
10945 ASSERT(args.length() == 0); | 10688 ASSERT(args.length() == 0); |
10946 | 10689 |
10947 // Fill the script objects. | 10690 // Fill the script objects. |
10948 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); | 10691 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
10949 | 10692 |
10950 // Convert the script objects to proper JS objects. | 10693 // Convert the script objects to proper JS objects. |
10951 for (int i = 0; i < instances->length(); i++) { | 10694 for (int i = 0; i < instances->length(); i++) { |
10952 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); | 10695 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); |
10953 // Get the script wrapper in a local handle before calling GetScriptWrapper, | 10696 // Get the script wrapper in a local handle before calling GetScriptWrapper, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11034 | 10777 |
11035 // Return the number of referencing objects found. | 10778 // Return the number of referencing objects found. |
11036 return count; | 10779 return count; |
11037 } | 10780 } |
11038 | 10781 |
11039 | 10782 |
11040 // Scan the heap for objects with direct references to an object | 10783 // Scan the heap for objects with direct references to an object |
11041 // args[0]: the object to find references to | 10784 // args[0]: the object to find references to |
11042 // args[1]: constructor function for instances to exclude (Mirror) | 10785 // args[1]: constructor function for instances to exclude (Mirror) |
11043 // args[2]: the the maximum number of objects to return | 10786 // args[2]: the the maximum number of objects to return |
11044 static MaybeObject* Runtime_DebugReferencedBy(RUNTIME_CALLING_CONVENTION) { | 10787 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { |
11045 RUNTIME_GET_ISOLATE; | |
11046 ASSERT(args.length() == 3); | 10788 ASSERT(args.length() == 3); |
11047 | 10789 |
11048 // First perform a full GC in order to avoid references from dead objects. | 10790 // First perform a full GC in order to avoid references from dead objects. |
11049 isolate->heap()->CollectAllGarbage(false); | 10791 isolate->heap()->CollectAllGarbage(false); |
11050 | 10792 |
11051 // Check parameters. | 10793 // Check parameters. |
11052 CONVERT_CHECKED(JSObject, target, args[0]); | 10794 CONVERT_CHECKED(JSObject, target, args[0]); |
11053 Object* instance_filter = args[1]; | 10795 Object* instance_filter = args[1]; |
11054 RUNTIME_ASSERT(instance_filter->IsUndefined() || | 10796 RUNTIME_ASSERT(instance_filter->IsUndefined() || |
11055 instance_filter->IsJSObject()); | 10797 instance_filter->IsJSObject()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11115 } | 10857 } |
11116 | 10858 |
11117 // Return the number of referencing objects found. | 10859 // Return the number of referencing objects found. |
11118 return count; | 10860 return count; |
11119 } | 10861 } |
11120 | 10862 |
11121 | 10863 |
11122 // Scan the heap for objects constructed by a specific function. | 10864 // Scan the heap for objects constructed by a specific function. |
11123 // args[0]: the constructor to find instances of | 10865 // args[0]: the constructor to find instances of |
11124 // args[1]: the the maximum number of objects to return | 10866 // args[1]: the the maximum number of objects to return |
11125 static MaybeObject* Runtime_DebugConstructedBy(RUNTIME_CALLING_CONVENTION) { | 10867 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { |
11126 RUNTIME_GET_ISOLATE; | |
11127 ASSERT(args.length() == 2); | 10868 ASSERT(args.length() == 2); |
11128 | 10869 |
11129 // First perform a full GC in order to avoid dead objects. | 10870 // First perform a full GC in order to avoid dead objects. |
11130 isolate->heap()->CollectAllGarbage(false); | 10871 isolate->heap()->CollectAllGarbage(false); |
11131 | 10872 |
11132 // Check parameters. | 10873 // Check parameters. |
11133 CONVERT_CHECKED(JSFunction, constructor, args[0]); | 10874 CONVERT_CHECKED(JSFunction, constructor, args[0]); |
11134 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 10875 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
11135 RUNTIME_ASSERT(max_references >= 0); | 10876 RUNTIME_ASSERT(max_references >= 0); |
11136 | 10877 |
(...skipping 17 matching lines...) Expand all Loading... |
11154 isolate->context()->global_context()->array_function()); | 10895 isolate->context()->global_context()->array_function()); |
11155 if (!maybe_result->ToObject(&result)) return maybe_result; | 10896 if (!maybe_result->ToObject(&result)) return maybe_result; |
11156 } | 10897 } |
11157 JSArray::cast(result)->SetContent(instances); | 10898 JSArray::cast(result)->SetContent(instances); |
11158 return result; | 10899 return result; |
11159 } | 10900 } |
11160 | 10901 |
11161 | 10902 |
11162 // Find the effective prototype object as returned by __proto__. | 10903 // Find the effective prototype object as returned by __proto__. |
11163 // args[0]: the object to find the prototype for. | 10904 // args[0]: the object to find the prototype for. |
11164 static MaybeObject* Runtime_DebugGetPrototype(RUNTIME_CALLING_CONVENTION) { | 10905 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { |
11165 RUNTIME_GET_ISOLATE; | |
11166 ASSERT(args.length() == 1); | 10906 ASSERT(args.length() == 1); |
11167 | 10907 |
11168 CONVERT_CHECKED(JSObject, obj, args[0]); | 10908 CONVERT_CHECKED(JSObject, obj, args[0]); |
11169 | 10909 |
11170 // Use the __proto__ accessor. | 10910 // Use the __proto__ accessor. |
11171 return Accessors::ObjectPrototype.getter(obj, NULL); | 10911 return Accessors::ObjectPrototype.getter(obj, NULL); |
11172 } | 10912 } |
11173 | 10913 |
11174 | 10914 |
11175 static MaybeObject* Runtime_SystemBreak(RUNTIME_CALLING_CONVENTION) { | 10915 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { |
11176 RUNTIME_GET_ISOLATE; | |
11177 ASSERT(args.length() == 0); | 10916 ASSERT(args.length() == 0); |
11178 CPU::DebugBreak(); | 10917 CPU::DebugBreak(); |
11179 return isolate->heap()->undefined_value(); | 10918 return isolate->heap()->undefined_value(); |
11180 } | 10919 } |
11181 | 10920 |
11182 | 10921 |
11183 static MaybeObject* Runtime_DebugDisassembleFunction( | 10922 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { |
11184 RUNTIME_CALLING_CONVENTION) { | |
11185 RUNTIME_GET_ISOLATE; | |
11186 #ifdef DEBUG | 10923 #ifdef DEBUG |
11187 HandleScope scope(isolate); | 10924 HandleScope scope(isolate); |
11188 ASSERT(args.length() == 1); | 10925 ASSERT(args.length() == 1); |
11189 // Get the function and make sure it is compiled. | 10926 // Get the function and make sure it is compiled. |
11190 CONVERT_ARG_CHECKED(JSFunction, func, 0); | 10927 CONVERT_ARG_CHECKED(JSFunction, func, 0); |
11191 Handle<SharedFunctionInfo> shared(func->shared()); | 10928 Handle<SharedFunctionInfo> shared(func->shared()); |
11192 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) { | 10929 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) { |
11193 return Failure::Exception(); | 10930 return Failure::Exception(); |
11194 } | 10931 } |
11195 func->code()->PrintLn(); | 10932 func->code()->PrintLn(); |
11196 #endif // DEBUG | 10933 #endif // DEBUG |
11197 return isolate->heap()->undefined_value(); | 10934 return isolate->heap()->undefined_value(); |
11198 } | 10935 } |
11199 | 10936 |
11200 | 10937 |
11201 static MaybeObject* Runtime_DebugDisassembleConstructor( | 10938 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { |
11202 RUNTIME_CALLING_CONVENTION) { | |
11203 RUNTIME_GET_ISOLATE; | |
11204 #ifdef DEBUG | 10939 #ifdef DEBUG |
11205 HandleScope scope(isolate); | 10940 HandleScope scope(isolate); |
11206 ASSERT(args.length() == 1); | 10941 ASSERT(args.length() == 1); |
11207 // Get the function and make sure it is compiled. | 10942 // Get the function and make sure it is compiled. |
11208 CONVERT_ARG_CHECKED(JSFunction, func, 0); | 10943 CONVERT_ARG_CHECKED(JSFunction, func, 0); |
11209 Handle<SharedFunctionInfo> shared(func->shared()); | 10944 Handle<SharedFunctionInfo> shared(func->shared()); |
11210 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) { | 10945 if (!EnsureCompiled(shared, KEEP_EXCEPTION)) { |
11211 return Failure::Exception(); | 10946 return Failure::Exception(); |
11212 } | 10947 } |
11213 shared->construct_stub()->PrintLn(); | 10948 shared->construct_stub()->PrintLn(); |
11214 #endif // DEBUG | 10949 #endif // DEBUG |
11215 return isolate->heap()->undefined_value(); | 10950 return isolate->heap()->undefined_value(); |
11216 } | 10951 } |
11217 | 10952 |
11218 | 10953 |
11219 static MaybeObject* Runtime_FunctionGetInferredName( | 10954 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { |
11220 RUNTIME_CALLING_CONVENTION) { | |
11221 RUNTIME_GET_ISOLATE; | |
11222 NoHandleAllocation ha; | 10955 NoHandleAllocation ha; |
11223 ASSERT(args.length() == 1); | 10956 ASSERT(args.length() == 1); |
11224 | 10957 |
11225 CONVERT_CHECKED(JSFunction, f, args[0]); | 10958 CONVERT_CHECKED(JSFunction, f, args[0]); |
11226 return f->shared()->inferred_name(); | 10959 return f->shared()->inferred_name(); |
11227 } | 10960 } |
11228 | 10961 |
11229 | 10962 |
11230 static int FindSharedFunctionInfosForScript(Script* script, | 10963 static int FindSharedFunctionInfosForScript(Script* script, |
11231 FixedArray* buffer) { | 10964 FixedArray* buffer) { |
(...skipping 15 matching lines...) Expand all Loading... |
11247 buffer->set(counter, shared); | 10980 buffer->set(counter, shared); |
11248 } | 10981 } |
11249 counter++; | 10982 counter++; |
11250 } | 10983 } |
11251 return counter; | 10984 return counter; |
11252 } | 10985 } |
11253 | 10986 |
11254 // For a script finds all SharedFunctionInfo's in the heap that points | 10987 // For a script finds all SharedFunctionInfo's in the heap that points |
11255 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 10988 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
11256 // in OpaqueReferences. | 10989 // in OpaqueReferences. |
11257 static MaybeObject* Runtime_LiveEditFindSharedFunctionInfosForScript( | 10990 RUNTIME_FUNCTION(MaybeObject*, |
11258 RUNTIME_CALLING_CONVENTION) { | 10991 Runtime_LiveEditFindSharedFunctionInfosForScript) { |
11259 RUNTIME_GET_ISOLATE; | |
11260 ASSERT(args.length() == 1); | 10992 ASSERT(args.length() == 1); |
11261 HandleScope scope(isolate); | 10993 HandleScope scope(isolate); |
11262 CONVERT_CHECKED(JSValue, script_value, args[0]); | 10994 CONVERT_CHECKED(JSValue, script_value, args[0]); |
11263 | 10995 |
11264 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 10996 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
11265 | 10997 |
11266 const int kBufferSize = 32; | 10998 const int kBufferSize = 32; |
11267 | 10999 |
11268 Handle<FixedArray> array; | 11000 Handle<FixedArray> array; |
11269 array = isolate->factory()->NewFixedArray(kBufferSize); | 11001 array = isolate->factory()->NewFixedArray(kBufferSize); |
(...skipping 11 matching lines...) Expand all Loading... |
11281 return *result; | 11013 return *result; |
11282 } | 11014 } |
11283 | 11015 |
11284 // For a script calculates compilation information about all its functions. | 11016 // For a script calculates compilation information about all its functions. |
11285 // The script source is explicitly specified by the second argument. | 11017 // The script source is explicitly specified by the second argument. |
11286 // The source of the actual script is not used, however it is important that | 11018 // The source of the actual script is not used, however it is important that |
11287 // all generated code keeps references to this particular instance of script. | 11019 // all generated code keeps references to this particular instance of script. |
11288 // Returns a JSArray of compilation infos. The array is ordered so that | 11020 // Returns a JSArray of compilation infos. The array is ordered so that |
11289 // each function with all its descendant is always stored in a continues range | 11021 // each function with all its descendant is always stored in a continues range |
11290 // with the function itself going first. The root function is a script function. | 11022 // with the function itself going first. The root function is a script function. |
11291 static MaybeObject* Runtime_LiveEditGatherCompileInfo( | 11023 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { |
11292 RUNTIME_CALLING_CONVENTION) { | |
11293 RUNTIME_GET_ISOLATE; | |
11294 ASSERT(args.length() == 2); | 11024 ASSERT(args.length() == 2); |
11295 HandleScope scope(isolate); | 11025 HandleScope scope(isolate); |
11296 CONVERT_CHECKED(JSValue, script, args[0]); | 11026 CONVERT_CHECKED(JSValue, script, args[0]); |
11297 CONVERT_ARG_CHECKED(String, source, 1); | 11027 CONVERT_ARG_CHECKED(String, source, 1); |
11298 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 11028 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
11299 | 11029 |
11300 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); | 11030 JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); |
11301 | 11031 |
11302 if (isolate->has_pending_exception()) { | 11032 if (isolate->has_pending_exception()) { |
11303 return Failure::Exception(); | 11033 return Failure::Exception(); |
11304 } | 11034 } |
11305 | 11035 |
11306 return result; | 11036 return result; |
11307 } | 11037 } |
11308 | 11038 |
11309 // Changes the source of the script to a new_source. | 11039 // Changes the source of the script to a new_source. |
11310 // If old_script_name is provided (i.e. is a String), also creates a copy of | 11040 // If old_script_name is provided (i.e. is a String), also creates a copy of |
11311 // the script with its original source and sends notification to debugger. | 11041 // the script with its original source and sends notification to debugger. |
11312 static MaybeObject* Runtime_LiveEditReplaceScript(RUNTIME_CALLING_CONVENTION) { | 11042 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { |
11313 RUNTIME_GET_ISOLATE; | |
11314 ASSERT(args.length() == 3); | 11043 ASSERT(args.length() == 3); |
11315 HandleScope scope(isolate); | 11044 HandleScope scope(isolate); |
11316 CONVERT_CHECKED(JSValue, original_script_value, args[0]); | 11045 CONVERT_CHECKED(JSValue, original_script_value, args[0]); |
11317 CONVERT_ARG_CHECKED(String, new_source, 1); | 11046 CONVERT_ARG_CHECKED(String, new_source, 1); |
11318 Handle<Object> old_script_name(args[2], isolate); | 11047 Handle<Object> old_script_name(args[2], isolate); |
11319 | 11048 |
11320 CONVERT_CHECKED(Script, original_script_pointer, | 11049 CONVERT_CHECKED(Script, original_script_pointer, |
11321 original_script_value->value()); | 11050 original_script_value->value()); |
11322 Handle<Script> original_script(original_script_pointer); | 11051 Handle<Script> original_script(original_script_pointer); |
11323 | 11052 |
11324 Object* old_script = LiveEdit::ChangeScriptSource(original_script, | 11053 Object* old_script = LiveEdit::ChangeScriptSource(original_script, |
11325 new_source, | 11054 new_source, |
11326 old_script_name); | 11055 old_script_name); |
11327 | 11056 |
11328 if (old_script->IsScript()) { | 11057 if (old_script->IsScript()) { |
11329 Handle<Script> script_handle(Script::cast(old_script)); | 11058 Handle<Script> script_handle(Script::cast(old_script)); |
11330 return *(GetScriptWrapper(script_handle)); | 11059 return *(GetScriptWrapper(script_handle)); |
11331 } else { | 11060 } else { |
11332 return isolate->heap()->null_value(); | 11061 return isolate->heap()->null_value(); |
11333 } | 11062 } |
11334 } | 11063 } |
11335 | 11064 |
11336 | 11065 |
11337 static MaybeObject* Runtime_LiveEditFunctionSourceUpdated( | 11066 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { |
11338 RUNTIME_CALLING_CONVENTION) { | |
11339 RUNTIME_GET_ISOLATE; | |
11340 ASSERT(args.length() == 1); | 11067 ASSERT(args.length() == 1); |
11341 HandleScope scope(isolate); | 11068 HandleScope scope(isolate); |
11342 CONVERT_ARG_CHECKED(JSArray, shared_info, 0); | 11069 CONVERT_ARG_CHECKED(JSArray, shared_info, 0); |
11343 return LiveEdit::FunctionSourceUpdated(shared_info); | 11070 return LiveEdit::FunctionSourceUpdated(shared_info); |
11344 } | 11071 } |
11345 | 11072 |
11346 | 11073 |
11347 // Replaces code of SharedFunctionInfo with a new one. | 11074 // Replaces code of SharedFunctionInfo with a new one. |
11348 static MaybeObject* Runtime_LiveEditReplaceFunctionCode( | 11075 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { |
11349 RUNTIME_CALLING_CONVENTION) { | |
11350 RUNTIME_GET_ISOLATE; | |
11351 ASSERT(args.length() == 2); | 11076 ASSERT(args.length() == 2); |
11352 HandleScope scope(isolate); | 11077 HandleScope scope(isolate); |
11353 CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0); | 11078 CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0); |
11354 CONVERT_ARG_CHECKED(JSArray, shared_info, 1); | 11079 CONVERT_ARG_CHECKED(JSArray, shared_info, 1); |
11355 | 11080 |
11356 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 11081 return LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
11357 } | 11082 } |
11358 | 11083 |
11359 // Connects SharedFunctionInfo to another script. | 11084 // Connects SharedFunctionInfo to another script. |
11360 static MaybeObject* Runtime_LiveEditFunctionSetScript( | 11085 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { |
11361 RUNTIME_CALLING_CONVENTION) { | |
11362 RUNTIME_GET_ISOLATE; | |
11363 ASSERT(args.length() == 2); | 11086 ASSERT(args.length() == 2); |
11364 HandleScope scope(isolate); | 11087 HandleScope scope(isolate); |
11365 Handle<Object> function_object(args[0], isolate); | 11088 Handle<Object> function_object(args[0], isolate); |
11366 Handle<Object> script_object(args[1], isolate); | 11089 Handle<Object> script_object(args[1], isolate); |
11367 | 11090 |
11368 if (function_object->IsJSValue()) { | 11091 if (function_object->IsJSValue()) { |
11369 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 11092 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
11370 if (script_object->IsJSValue()) { | 11093 if (script_object->IsJSValue()) { |
11371 CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value()); | 11094 CONVERT_CHECKED(Script, script, JSValue::cast(*script_object)->value()); |
11372 script_object = Handle<Object>(script, isolate); | 11095 script_object = Handle<Object>(script, isolate); |
11373 } | 11096 } |
11374 | 11097 |
11375 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 11098 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
11376 } else { | 11099 } else { |
11377 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 11100 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
11378 // and we check it in this function. | 11101 // and we check it in this function. |
11379 } | 11102 } |
11380 | 11103 |
11381 return isolate->heap()->undefined_value(); | 11104 return isolate->heap()->undefined_value(); |
11382 } | 11105 } |
11383 | 11106 |
11384 | 11107 |
11385 // In a code of a parent function replaces original function as embedded object | 11108 // In a code of a parent function replaces original function as embedded object |
11386 // with a substitution one. | 11109 // with a substitution one. |
11387 static MaybeObject* Runtime_LiveEditReplaceRefToNestedFunction( | 11110 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) { |
11388 RUNTIME_CALLING_CONVENTION) { | |
11389 RUNTIME_GET_ISOLATE; | |
11390 ASSERT(args.length() == 3); | 11111 ASSERT(args.length() == 3); |
11391 HandleScope scope(isolate); | 11112 HandleScope scope(isolate); |
11392 | 11113 |
11393 CONVERT_ARG_CHECKED(JSValue, parent_wrapper, 0); | 11114 CONVERT_ARG_CHECKED(JSValue, parent_wrapper, 0); |
11394 CONVERT_ARG_CHECKED(JSValue, orig_wrapper, 1); | 11115 CONVERT_ARG_CHECKED(JSValue, orig_wrapper, 1); |
11395 CONVERT_ARG_CHECKED(JSValue, subst_wrapper, 2); | 11116 CONVERT_ARG_CHECKED(JSValue, subst_wrapper, 2); |
11396 | 11117 |
11397 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, | 11118 LiveEdit::ReplaceRefToNestedFunction(parent_wrapper, orig_wrapper, |
11398 subst_wrapper); | 11119 subst_wrapper); |
11399 | 11120 |
11400 return isolate->heap()->undefined_value(); | 11121 return isolate->heap()->undefined_value(); |
11401 } | 11122 } |
11402 | 11123 |
11403 | 11124 |
11404 // Updates positions of a shared function info (first parameter) according | 11125 // Updates positions of a shared function info (first parameter) according |
11405 // to script source change. Text change is described in second parameter as | 11126 // to script source change. Text change is described in second parameter as |
11406 // array of groups of 3 numbers: | 11127 // array of groups of 3 numbers: |
11407 // (change_begin, change_end, change_end_new_position). | 11128 // (change_begin, change_end, change_end_new_position). |
11408 // Each group describes a change in text; groups are sorted by change_begin. | 11129 // Each group describes a change in text; groups are sorted by change_begin. |
11409 static MaybeObject* Runtime_LiveEditPatchFunctionPositions( | 11130 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) { |
11410 RUNTIME_CALLING_CONVENTION) { | |
11411 RUNTIME_GET_ISOLATE; | |
11412 ASSERT(args.length() == 2); | 11131 ASSERT(args.length() == 2); |
11413 HandleScope scope(isolate); | 11132 HandleScope scope(isolate); |
11414 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 11133 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
11415 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); | 11134 CONVERT_ARG_CHECKED(JSArray, position_change_array, 1); |
11416 | 11135 |
11417 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 11136 return LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
11418 } | 11137 } |
11419 | 11138 |
11420 | 11139 |
11421 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 11140 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
11422 // checks that none of them have activations on stacks (of any thread). | 11141 // checks that none of them have activations on stacks (of any thread). |
11423 // Returns array of the same length with corresponding results of | 11142 // Returns array of the same length with corresponding results of |
11424 // LiveEdit::FunctionPatchabilityStatus type. | 11143 // LiveEdit::FunctionPatchabilityStatus type. |
11425 static MaybeObject* Runtime_LiveEditCheckAndDropActivations( | 11144 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { |
11426 RUNTIME_CALLING_CONVENTION) { | |
11427 RUNTIME_GET_ISOLATE; | |
11428 ASSERT(args.length() == 2); | 11145 ASSERT(args.length() == 2); |
11429 HandleScope scope(isolate); | 11146 HandleScope scope(isolate); |
11430 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); | 11147 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); |
11431 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); | 11148 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); |
11432 | 11149 |
11433 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 11150 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
11434 } | 11151 } |
11435 | 11152 |
11436 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 11153 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
11437 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 11154 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
11438 // of diff chunks. | 11155 // of diff chunks. |
11439 static MaybeObject* Runtime_LiveEditCompareStrings(RUNTIME_CALLING_CONVENTION) { | 11156 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { |
11440 RUNTIME_GET_ISOLATE; | |
11441 ASSERT(args.length() == 2); | 11157 ASSERT(args.length() == 2); |
11442 HandleScope scope(isolate); | 11158 HandleScope scope(isolate); |
11443 CONVERT_ARG_CHECKED(String, s1, 0); | 11159 CONVERT_ARG_CHECKED(String, s1, 0); |
11444 CONVERT_ARG_CHECKED(String, s2, 1); | 11160 CONVERT_ARG_CHECKED(String, s2, 1); |
11445 | 11161 |
11446 return *LiveEdit::CompareStrings(s1, s2); | 11162 return *LiveEdit::CompareStrings(s1, s2); |
11447 } | 11163 } |
11448 | 11164 |
11449 | 11165 |
11450 // A testing entry. Returns statement position which is the closest to | 11166 // A testing entry. Returns statement position which is the closest to |
11451 // source_position. | 11167 // source_position. |
11452 static MaybeObject* Runtime_GetFunctionCodePositionFromSource( | 11168 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { |
11453 RUNTIME_CALLING_CONVENTION) { | |
11454 RUNTIME_GET_ISOLATE; | |
11455 ASSERT(args.length() == 2); | 11169 ASSERT(args.length() == 2); |
11456 HandleScope scope(isolate); | 11170 HandleScope scope(isolate); |
11457 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 11171 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
11458 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 11172 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
11459 | 11173 |
11460 Handle<Code> code(function->code(), isolate); | 11174 Handle<Code> code(function->code(), isolate); |
11461 | 11175 |
11462 if (code->kind() != Code::FUNCTION && | 11176 if (code->kind() != Code::FUNCTION && |
11463 code->kind() != Code::OPTIMIZED_FUNCTION) { | 11177 code->kind() != Code::OPTIMIZED_FUNCTION) { |
11464 return isolate->heap()->undefined_value(); | 11178 return isolate->heap()->undefined_value(); |
(...skipping 16 matching lines...) Expand all Loading... |
11481 it.next(); | 11195 it.next(); |
11482 } | 11196 } |
11483 | 11197 |
11484 return Smi::FromInt(closest_pc); | 11198 return Smi::FromInt(closest_pc); |
11485 } | 11199 } |
11486 | 11200 |
11487 | 11201 |
11488 // Calls specified function with or without entering the debugger. | 11202 // Calls specified function with or without entering the debugger. |
11489 // This is used in unit tests to run code as if debugger is entered or simply | 11203 // This is used in unit tests to run code as if debugger is entered or simply |
11490 // to have a stack with C++ frame in the middle. | 11204 // to have a stack with C++ frame in the middle. |
11491 static MaybeObject* Runtime_ExecuteInDebugContext(RUNTIME_CALLING_CONVENTION) { | 11205 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { |
11492 RUNTIME_GET_ISOLATE; | |
11493 ASSERT(args.length() == 2); | 11206 ASSERT(args.length() == 2); |
11494 HandleScope scope(isolate); | 11207 HandleScope scope(isolate); |
11495 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 11208 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
11496 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); | 11209 CONVERT_BOOLEAN_CHECKED(without_debugger, args[1]); |
11497 | 11210 |
11498 Handle<Object> result; | 11211 Handle<Object> result; |
11499 bool pending_exception; | 11212 bool pending_exception; |
11500 { | 11213 { |
11501 if (without_debugger) { | 11214 if (without_debugger) { |
11502 result = Execution::Call(function, isolate->global(), 0, NULL, | 11215 result = Execution::Call(function, isolate->global(), 0, NULL, |
11503 &pending_exception); | 11216 &pending_exception); |
11504 } else { | 11217 } else { |
11505 EnterDebugger enter_debugger; | 11218 EnterDebugger enter_debugger; |
11506 result = Execution::Call(function, isolate->global(), 0, NULL, | 11219 result = Execution::Call(function, isolate->global(), 0, NULL, |
11507 &pending_exception); | 11220 &pending_exception); |
11508 } | 11221 } |
11509 } | 11222 } |
11510 if (!pending_exception) { | 11223 if (!pending_exception) { |
11511 return *result; | 11224 return *result; |
11512 } else { | 11225 } else { |
11513 return Failure::Exception(); | 11226 return Failure::Exception(); |
11514 } | 11227 } |
11515 } | 11228 } |
11516 | 11229 |
11517 | 11230 |
11518 // Sets a v8 flag. | 11231 // Sets a v8 flag. |
11519 static MaybeObject* Runtime_SetFlags(RUNTIME_CALLING_CONVENTION) { | 11232 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { |
11520 RUNTIME_GET_ISOLATE; | |
11521 CONVERT_CHECKED(String, arg, args[0]); | 11233 CONVERT_CHECKED(String, arg, args[0]); |
11522 SmartPointer<char> flags = | 11234 SmartPointer<char> flags = |
11523 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 11235 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
11524 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); | 11236 FlagList::SetFlagsFromString(*flags, StrLength(*flags)); |
11525 return isolate->heap()->undefined_value(); | 11237 return isolate->heap()->undefined_value(); |
11526 } | 11238 } |
11527 | 11239 |
11528 | 11240 |
11529 // Performs a GC. | 11241 // Performs a GC. |
11530 // Presently, it only does a full GC. | 11242 // Presently, it only does a full GC. |
11531 static MaybeObject* Runtime_CollectGarbage(RUNTIME_CALLING_CONVENTION) { | 11243 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { |
11532 RUNTIME_GET_ISOLATE; | |
11533 isolate->heap()->CollectAllGarbage(true); | 11244 isolate->heap()->CollectAllGarbage(true); |
11534 return isolate->heap()->undefined_value(); | 11245 return isolate->heap()->undefined_value(); |
11535 } | 11246 } |
11536 | 11247 |
11537 | 11248 |
11538 // Gets the current heap usage. | 11249 // Gets the current heap usage. |
11539 static MaybeObject* Runtime_GetHeapUsage(RUNTIME_CALLING_CONVENTION) { | 11250 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { |
11540 RUNTIME_GET_ISOLATE; | |
11541 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 11251 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
11542 if (!Smi::IsValid(usage)) { | 11252 if (!Smi::IsValid(usage)) { |
11543 return *isolate->factory()->NewNumberFromInt(usage); | 11253 return *isolate->factory()->NewNumberFromInt(usage); |
11544 } | 11254 } |
11545 return Smi::FromInt(usage); | 11255 return Smi::FromInt(usage); |
11546 } | 11256 } |
11547 | 11257 |
11548 | 11258 |
11549 // Captures a live object list from the present heap. | 11259 // Captures a live object list from the present heap. |
11550 static MaybeObject* Runtime_HasLOLEnabled(RUNTIME_CALLING_CONVENTION) { | 11260 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLOLEnabled) { |
11551 RUNTIME_GET_ISOLATE; | |
11552 #ifdef LIVE_OBJECT_LIST | 11261 #ifdef LIVE_OBJECT_LIST |
11553 return isolate->heap()->true_value(); | 11262 return isolate->heap()->true_value(); |
11554 #else | 11263 #else |
11555 return isolate->heap()->false_value(); | 11264 return isolate->heap()->false_value(); |
11556 #endif | 11265 #endif |
11557 } | 11266 } |
11558 | 11267 |
11559 | 11268 |
11560 // Captures a live object list from the present heap. | 11269 // Captures a live object list from the present heap. |
11561 static MaybeObject* Runtime_CaptureLOL(RUNTIME_CALLING_CONVENTION) { | 11270 RUNTIME_FUNCTION(MaybeObject*, Runtime_CaptureLOL) { |
11562 RUNTIME_GET_ISOLATE; | |
11563 #ifdef LIVE_OBJECT_LIST | 11271 #ifdef LIVE_OBJECT_LIST |
11564 return LiveObjectList::Capture(); | 11272 return LiveObjectList::Capture(); |
11565 #else | 11273 #else |
11566 return isolate->heap()->undefined_value(); | 11274 return isolate->heap()->undefined_value(); |
11567 #endif | 11275 #endif |
11568 } | 11276 } |
11569 | 11277 |
11570 | 11278 |
11571 // Deletes the specified live object list. | 11279 // Deletes the specified live object list. |
11572 static MaybeObject* Runtime_DeleteLOL(RUNTIME_CALLING_CONVENTION) { | 11280 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { |
11573 RUNTIME_GET_ISOLATE; | |
11574 #ifdef LIVE_OBJECT_LIST | 11281 #ifdef LIVE_OBJECT_LIST |
11575 CONVERT_SMI_CHECKED(id, args[0]); | 11282 CONVERT_SMI_CHECKED(id, args[0]); |
11576 bool success = LiveObjectList::Delete(id); | 11283 bool success = LiveObjectList::Delete(id); |
11577 return success ? isolate->heap()->true_value() : | 11284 return success ? isolate->heap()->true_value() : |
11578 isolate->heap()->false_value(); | 11285 isolate->heap()->false_value(); |
11579 #else | 11286 #else |
11580 return isolate->heap()->undefined_value(); | 11287 return isolate->heap()->undefined_value(); |
11581 #endif | 11288 #endif |
11582 } | 11289 } |
11583 | 11290 |
11584 | 11291 |
11585 // Generates the response to a debugger request for a dump of the objects | 11292 // Generates the response to a debugger request for a dump of the objects |
11586 // contained in the difference between the captured live object lists | 11293 // contained in the difference between the captured live object lists |
11587 // specified by id1 and id2. | 11294 // specified by id1 and id2. |
11588 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | 11295 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
11589 // dumped. | 11296 // dumped. |
11590 static MaybeObject* Runtime_DumpLOL(RUNTIME_CALLING_CONVENTION) { | 11297 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) { |
11591 RUNTIME_GET_ISOLATE; | |
11592 #ifdef LIVE_OBJECT_LIST | 11298 #ifdef LIVE_OBJECT_LIST |
11593 HandleScope scope; | 11299 HandleScope scope; |
11594 CONVERT_SMI_CHECKED(id1, args[0]); | 11300 CONVERT_SMI_CHECKED(id1, args[0]); |
11595 CONVERT_SMI_CHECKED(id2, args[1]); | 11301 CONVERT_SMI_CHECKED(id2, args[1]); |
11596 CONVERT_SMI_CHECKED(start, args[2]); | 11302 CONVERT_SMI_CHECKED(start, args[2]); |
11597 CONVERT_SMI_CHECKED(count, args[3]); | 11303 CONVERT_SMI_CHECKED(count, args[3]); |
11598 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); | 11304 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); |
11599 EnterDebugger enter_debugger; | 11305 EnterDebugger enter_debugger; |
11600 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); | 11306 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); |
11601 #else | 11307 #else |
11602 return isolate->heap()->undefined_value(); | 11308 return isolate->heap()->undefined_value(); |
11603 #endif | 11309 #endif |
11604 } | 11310 } |
11605 | 11311 |
11606 | 11312 |
11607 // Gets the specified object as requested by the debugger. | 11313 // Gets the specified object as requested by the debugger. |
11608 // This is only used for obj ids shown in live object lists. | 11314 // This is only used for obj ids shown in live object lists. |
11609 static MaybeObject* Runtime_GetLOLObj(RUNTIME_CALLING_CONVENTION) { | 11315 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) { |
11610 RUNTIME_GET_ISOLATE; | |
11611 #ifdef LIVE_OBJECT_LIST | 11316 #ifdef LIVE_OBJECT_LIST |
11612 CONVERT_SMI_CHECKED(obj_id, args[0]); | 11317 CONVERT_SMI_CHECKED(obj_id, args[0]); |
11613 Object* result = LiveObjectList::GetObj(obj_id); | 11318 Object* result = LiveObjectList::GetObj(obj_id); |
11614 return result; | 11319 return result; |
11615 #else | 11320 #else |
11616 return isolate->heap()->undefined_value(); | 11321 return isolate->heap()->undefined_value(); |
11617 #endif | 11322 #endif |
11618 } | 11323 } |
11619 | 11324 |
11620 | 11325 |
11621 // Gets the obj id for the specified address if valid. | 11326 // Gets the obj id for the specified address if valid. |
11622 // This is only used for obj ids shown in live object lists. | 11327 // This is only used for obj ids shown in live object lists. |
11623 static MaybeObject* Runtime_GetLOLObjId(RUNTIME_CALLING_CONVENTION) { | 11328 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) { |
11624 RUNTIME_GET_ISOLATE; | |
11625 #ifdef LIVE_OBJECT_LIST | 11329 #ifdef LIVE_OBJECT_LIST |
11626 HandleScope scope; | 11330 HandleScope scope; |
11627 CONVERT_ARG_CHECKED(String, address, 0); | 11331 CONVERT_ARG_CHECKED(String, address, 0); |
11628 Object* result = LiveObjectList::GetObjId(address); | 11332 Object* result = LiveObjectList::GetObjId(address); |
11629 return result; | 11333 return result; |
11630 #else | 11334 #else |
11631 return isolate->heap()->undefined_value(); | 11335 return isolate->heap()->undefined_value(); |
11632 #endif | 11336 #endif |
11633 } | 11337 } |
11634 | 11338 |
11635 | 11339 |
11636 // Gets the retainers that references the specified object alive. | 11340 // Gets the retainers that references the specified object alive. |
11637 static MaybeObject* Runtime_GetLOLObjRetainers(RUNTIME_CALLING_CONVENTION) { | 11341 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) { |
11638 RUNTIME_GET_ISOLATE; | |
11639 #ifdef LIVE_OBJECT_LIST | 11342 #ifdef LIVE_OBJECT_LIST |
11640 HandleScope scope; | 11343 HandleScope scope; |
11641 CONVERT_SMI_CHECKED(obj_id, args[0]); | 11344 CONVERT_SMI_CHECKED(obj_id, args[0]); |
11642 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); | 11345 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); |
11643 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); | 11346 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); |
11644 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); | 11347 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); |
11645 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); | 11348 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); |
11646 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); | 11349 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); |
11647 | 11350 |
11648 Handle<JSObject> instance_filter; | 11351 Handle<JSObject> instance_filter; |
(...skipping 19 matching lines...) Expand all Loading... |
11668 start, | 11371 start, |
11669 limit, | 11372 limit, |
11670 filter_obj); | 11373 filter_obj); |
11671 #else | 11374 #else |
11672 return isolate->heap()->undefined_value(); | 11375 return isolate->heap()->undefined_value(); |
11673 #endif | 11376 #endif |
11674 } | 11377 } |
11675 | 11378 |
11676 | 11379 |
11677 // Gets the reference path between 2 objects. | 11380 // Gets the reference path between 2 objects. |
11678 static MaybeObject* Runtime_GetLOLPath(RUNTIME_CALLING_CONVENTION) { | 11381 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLPath) { |
11679 RUNTIME_GET_ISOLATE; | |
11680 #ifdef LIVE_OBJECT_LIST | 11382 #ifdef LIVE_OBJECT_LIST |
11681 HandleScope scope; | 11383 HandleScope scope; |
11682 CONVERT_SMI_CHECKED(obj_id1, args[0]); | 11384 CONVERT_SMI_CHECKED(obj_id1, args[0]); |
11683 CONVERT_SMI_CHECKED(obj_id2, args[1]); | 11385 CONVERT_SMI_CHECKED(obj_id2, args[1]); |
11684 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); | 11386 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); |
11685 | 11387 |
11686 Handle<JSObject> instance_filter; | 11388 Handle<JSObject> instance_filter; |
11687 if (args[2]->IsJSObject()) { | 11389 if (args[2]->IsJSObject()) { |
11688 instance_filter = args.at<JSObject>(2); | 11390 instance_filter = args.at<JSObject>(2); |
11689 } | 11391 } |
11690 | 11392 |
11691 Object* result = | 11393 Object* result = |
11692 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); | 11394 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); |
11693 return result; | 11395 return result; |
11694 #else | 11396 #else |
11695 return isolate->heap()->undefined_value(); | 11397 return isolate->heap()->undefined_value(); |
11696 #endif | 11398 #endif |
11697 } | 11399 } |
11698 | 11400 |
11699 | 11401 |
11700 // Generates the response to a debugger request for a list of all | 11402 // Generates the response to a debugger request for a list of all |
11701 // previously captured live object lists. | 11403 // previously captured live object lists. |
11702 static MaybeObject* Runtime_InfoLOL(RUNTIME_CALLING_CONVENTION) { | 11404 RUNTIME_FUNCTION(MaybeObject*, Runtime_InfoLOL) { |
11703 RUNTIME_GET_ISOLATE; | |
11704 #ifdef LIVE_OBJECT_LIST | 11405 #ifdef LIVE_OBJECT_LIST |
11705 CONVERT_SMI_CHECKED(start, args[0]); | 11406 CONVERT_SMI_CHECKED(start, args[0]); |
11706 CONVERT_SMI_CHECKED(count, args[1]); | 11407 CONVERT_SMI_CHECKED(count, args[1]); |
11707 return LiveObjectList::Info(start, count); | 11408 return LiveObjectList::Info(start, count); |
11708 #else | 11409 #else |
11709 return isolate->heap()->undefined_value(); | 11410 return isolate->heap()->undefined_value(); |
11710 #endif | 11411 #endif |
11711 } | 11412 } |
11712 | 11413 |
11713 | 11414 |
11714 // Gets a dump of the specified object as requested by the debugger. | 11415 // Gets a dump of the specified object as requested by the debugger. |
11715 // This is only used for obj ids shown in live object lists. | 11416 // This is only used for obj ids shown in live object lists. |
11716 static MaybeObject* Runtime_PrintLOLObj(RUNTIME_CALLING_CONVENTION) { | 11417 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrintLOLObj) { |
11717 RUNTIME_GET_ISOLATE; | |
11718 #ifdef LIVE_OBJECT_LIST | 11418 #ifdef LIVE_OBJECT_LIST |
11719 HandleScope scope; | 11419 HandleScope scope; |
11720 CONVERT_SMI_CHECKED(obj_id, args[0]); | 11420 CONVERT_SMI_CHECKED(obj_id, args[0]); |
11721 Object* result = LiveObjectList::PrintObj(obj_id); | 11421 Object* result = LiveObjectList::PrintObj(obj_id); |
11722 return result; | 11422 return result; |
11723 #else | 11423 #else |
11724 return isolate->heap()->undefined_value(); | 11424 return isolate->heap()->undefined_value(); |
11725 #endif | 11425 #endif |
11726 } | 11426 } |
11727 | 11427 |
11728 | 11428 |
11729 // Resets and releases all previously captured live object lists. | 11429 // Resets and releases all previously captured live object lists. |
11730 static MaybeObject* Runtime_ResetLOL(RUNTIME_CALLING_CONVENTION) { | 11430 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResetLOL) { |
11731 RUNTIME_GET_ISOLATE; | |
11732 #ifdef LIVE_OBJECT_LIST | 11431 #ifdef LIVE_OBJECT_LIST |
11733 LiveObjectList::Reset(); | 11432 LiveObjectList::Reset(); |
11734 return isolate->heap()->undefined_value(); | 11433 return isolate->heap()->undefined_value(); |
11735 #else | 11434 #else |
11736 return isolate->heap()->undefined_value(); | 11435 return isolate->heap()->undefined_value(); |
11737 #endif | 11436 #endif |
11738 } | 11437 } |
11739 | 11438 |
11740 | 11439 |
11741 // Generates the response to a debugger request for a summary of the types | 11440 // Generates the response to a debugger request for a summary of the types |
11742 // of objects in the difference between the captured live object lists | 11441 // of objects in the difference between the captured live object lists |
11743 // specified by id1 and id2. | 11442 // specified by id1 and id2. |
11744 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | 11443 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
11745 // summarized. | 11444 // summarized. |
11746 static MaybeObject* Runtime_SummarizeLOL(RUNTIME_CALLING_CONVENTION) { | 11445 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) { |
11747 RUNTIME_GET_ISOLATE; | |
11748 #ifdef LIVE_OBJECT_LIST | 11446 #ifdef LIVE_OBJECT_LIST |
11749 HandleScope scope; | 11447 HandleScope scope; |
11750 CONVERT_SMI_CHECKED(id1, args[0]); | 11448 CONVERT_SMI_CHECKED(id1, args[0]); |
11751 CONVERT_SMI_CHECKED(id2, args[1]); | 11449 CONVERT_SMI_CHECKED(id2, args[1]); |
11752 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); | 11450 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); |
11753 | 11451 |
11754 EnterDebugger enter_debugger; | 11452 EnterDebugger enter_debugger; |
11755 return LiveObjectList::Summarize(id1, id2, filter_obj); | 11453 return LiveObjectList::Summarize(id1, id2, filter_obj); |
11756 #else | 11454 #else |
11757 return isolate->heap()->undefined_value(); | 11455 return isolate->heap()->undefined_value(); |
11758 #endif | 11456 #endif |
11759 } | 11457 } |
11760 | 11458 |
11761 #endif // ENABLE_DEBUGGER_SUPPORT | 11459 #endif // ENABLE_DEBUGGER_SUPPORT |
11762 | 11460 |
11763 | 11461 |
11764 #ifdef ENABLE_LOGGING_AND_PROFILING | 11462 #ifdef ENABLE_LOGGING_AND_PROFILING |
11765 static MaybeObject* Runtime_ProfilerResume(RUNTIME_CALLING_CONVENTION) { | 11463 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
11766 RUNTIME_GET_ISOLATE; | |
11767 NoHandleAllocation ha; | 11464 NoHandleAllocation ha; |
11768 ASSERT(args.length() == 2); | 11465 ASSERT(args.length() == 2); |
11769 | 11466 |
11770 CONVERT_CHECKED(Smi, smi_modules, args[0]); | 11467 CONVERT_CHECKED(Smi, smi_modules, args[0]); |
11771 CONVERT_CHECKED(Smi, smi_tag, args[1]); | 11468 CONVERT_CHECKED(Smi, smi_tag, args[1]); |
11772 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value()); | 11469 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value()); |
11773 return isolate->heap()->undefined_value(); | 11470 return isolate->heap()->undefined_value(); |
11774 } | 11471 } |
11775 | 11472 |
11776 | 11473 |
11777 static MaybeObject* Runtime_ProfilerPause(RUNTIME_CALLING_CONVENTION) { | 11474 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { |
11778 RUNTIME_GET_ISOLATE; | |
11779 NoHandleAllocation ha; | 11475 NoHandleAllocation ha; |
11780 ASSERT(args.length() == 2); | 11476 ASSERT(args.length() == 2); |
11781 | 11477 |
11782 CONVERT_CHECKED(Smi, smi_modules, args[0]); | 11478 CONVERT_CHECKED(Smi, smi_modules, args[0]); |
11783 CONVERT_CHECKED(Smi, smi_tag, args[1]); | 11479 CONVERT_CHECKED(Smi, smi_tag, args[1]); |
11784 v8::V8::PauseProfilerEx(smi_modules->value(), smi_tag->value()); | 11480 v8::V8::PauseProfilerEx(smi_modules->value(), smi_tag->value()); |
11785 return isolate->heap()->undefined_value(); | 11481 return isolate->heap()->undefined_value(); |
11786 } | 11482 } |
11787 | 11483 |
11788 #endif // ENABLE_LOGGING_AND_PROFILING | 11484 #endif // ENABLE_LOGGING_AND_PROFILING |
(...skipping 26 matching lines...) Expand all Loading... |
11815 if (script.is_null()) return FACTORY->undefined_value(); | 11511 if (script.is_null()) return FACTORY->undefined_value(); |
11816 | 11512 |
11817 // Return the script found. | 11513 // Return the script found. |
11818 return GetScriptWrapper(script); | 11514 return GetScriptWrapper(script); |
11819 } | 11515 } |
11820 | 11516 |
11821 | 11517 |
11822 // Get the script object from script data. NOTE: Regarding performance | 11518 // Get the script object from script data. NOTE: Regarding performance |
11823 // see the NOTE for GetScriptFromScriptData. | 11519 // see the NOTE for GetScriptFromScriptData. |
11824 // args[0]: script data for the script to find the source for | 11520 // args[0]: script data for the script to find the source for |
11825 static MaybeObject* Runtime_GetScript(RUNTIME_CALLING_CONVENTION) { | 11521 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { |
11826 RUNTIME_GET_ISOLATE; | |
11827 HandleScope scope(isolate); | 11522 HandleScope scope(isolate); |
11828 | 11523 |
11829 ASSERT(args.length() == 1); | 11524 ASSERT(args.length() == 1); |
11830 | 11525 |
11831 CONVERT_CHECKED(String, script_name, args[0]); | 11526 CONVERT_CHECKED(String, script_name, args[0]); |
11832 | 11527 |
11833 // Find the requested script. | 11528 // Find the requested script. |
11834 Handle<Object> result = | 11529 Handle<Object> result = |
11835 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 11530 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
11836 return *result; | 11531 return *result; |
(...skipping 24 matching lines...) Expand all Loading... |
11861 // obvious builtin calls. Some builtin calls (such as Number.ADD | 11556 // obvious builtin calls. Some builtin calls (such as Number.ADD |
11862 // which is invoked using 'call') are very difficult to recognize | 11557 // which is invoked using 'call') are very difficult to recognize |
11863 // so we're leaving them in for now. | 11558 // so we're leaving them in for now. |
11864 return *seen_caller && !frame->receiver()->IsJSBuiltinsObject(); | 11559 return *seen_caller && !frame->receiver()->IsJSBuiltinsObject(); |
11865 } | 11560 } |
11866 | 11561 |
11867 | 11562 |
11868 // Collect the raw data for a stack trace. Returns an array of 4 | 11563 // Collect the raw data for a stack trace. Returns an array of 4 |
11869 // element segments each containing a receiver, function, code and | 11564 // element segments each containing a receiver, function, code and |
11870 // native code offset. | 11565 // native code offset. |
11871 static MaybeObject* Runtime_CollectStackTrace(RUNTIME_CALLING_CONVENTION) { | 11566 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { |
11872 RUNTIME_GET_ISOLATE; | |
11873 ASSERT_EQ(args.length(), 2); | 11567 ASSERT_EQ(args.length(), 2); |
11874 Handle<Object> caller = args.at<Object>(0); | 11568 Handle<Object> caller = args.at<Object>(0); |
11875 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); | 11569 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]); |
11876 | 11570 |
11877 HandleScope scope(isolate); | 11571 HandleScope scope(isolate); |
11878 Factory* factory = isolate->factory(); | 11572 Factory* factory = isolate->factory(); |
11879 | 11573 |
11880 limit = Max(limit, 0); // Ensure that limit is not negative. | 11574 limit = Max(limit, 0); // Ensure that limit is not negative. |
11881 int initial_size = Min(limit, 10); | 11575 int initial_size = Min(limit, 10); |
11882 Handle<FixedArray> elements = | 11576 Handle<FixedArray> elements = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11919 } | 11613 } |
11920 iter.Advance(); | 11614 iter.Advance(); |
11921 } | 11615 } |
11922 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 11616 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
11923 result->set_length(Smi::FromInt(cursor)); | 11617 result->set_length(Smi::FromInt(cursor)); |
11924 return *result; | 11618 return *result; |
11925 } | 11619 } |
11926 | 11620 |
11927 | 11621 |
11928 // Returns V8 version as a string. | 11622 // Returns V8 version as a string. |
11929 static MaybeObject* Runtime_GetV8Version(RUNTIME_CALLING_CONVENTION) { | 11623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
11930 RUNTIME_GET_ISOLATE; | |
11931 ASSERT_EQ(args.length(), 0); | 11624 ASSERT_EQ(args.length(), 0); |
11932 | 11625 |
11933 NoHandleAllocation ha; | 11626 NoHandleAllocation ha; |
11934 | 11627 |
11935 const char* version_string = v8::V8::GetVersion(); | 11628 const char* version_string = v8::V8::GetVersion(); |
11936 | 11629 |
11937 return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string), | 11630 return isolate->heap()->AllocateStringFromAscii(CStrVector(version_string), |
11938 NOT_TENURED); | 11631 NOT_TENURED); |
11939 } | 11632 } |
11940 | 11633 |
11941 | 11634 |
11942 static MaybeObject* Runtime_Abort(RUNTIME_CALLING_CONVENTION) { | 11635 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { |
11943 RUNTIME_GET_ISOLATE; | |
11944 ASSERT(args.length() == 2); | 11636 ASSERT(args.length() == 2); |
11945 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + | 11637 OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) + |
11946 Smi::cast(args[1])->value()); | 11638 Smi::cast(args[1])->value()); |
11947 isolate->PrintStack(); | 11639 isolate->PrintStack(); |
11948 OS::Abort(); | 11640 OS::Abort(); |
11949 UNREACHABLE(); | 11641 UNREACHABLE(); |
11950 return NULL; | 11642 return NULL; |
11951 } | 11643 } |
11952 | 11644 |
11953 | 11645 |
11954 static MaybeObject* Runtime_GetFromCache(RUNTIME_CALLING_CONVENTION) { | 11646 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) { |
11955 RUNTIME_GET_ISOLATE; | |
11956 // This is only called from codegen, so checks might be more lax. | 11647 // This is only called from codegen, so checks might be more lax. |
11957 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]); | 11648 CONVERT_CHECKED(JSFunctionResultCache, cache, args[0]); |
11958 Object* key = args[1]; | 11649 Object* key = args[1]; |
11959 | 11650 |
11960 int finger_index = cache->finger_index(); | 11651 int finger_index = cache->finger_index(); |
11961 Object* o = cache->get(finger_index); | 11652 Object* o = cache->get(finger_index); |
11962 if (o == key) { | 11653 if (o == key) { |
11963 // The fastest case: hit the same place again. | 11654 // The fastest case: hit the same place again. |
11964 return cache->get(finger_index + 1); | 11655 return cache->get(finger_index + 1); |
11965 } | 11656 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12037 cache_handle->set_finger_index(index); | 11728 cache_handle->set_finger_index(index); |
12038 | 11729 |
12039 #ifdef DEBUG | 11730 #ifdef DEBUG |
12040 cache_handle->JSFunctionResultCacheVerify(); | 11731 cache_handle->JSFunctionResultCacheVerify(); |
12041 #endif | 11732 #endif |
12042 | 11733 |
12043 return *value; | 11734 return *value; |
12044 } | 11735 } |
12045 | 11736 |
12046 | 11737 |
12047 static MaybeObject* Runtime_NewMessageObject(RUNTIME_CALLING_CONVENTION) { | 11738 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewMessageObject) { |
12048 RUNTIME_GET_ISOLATE; | |
12049 HandleScope scope(isolate); | 11739 HandleScope scope(isolate); |
12050 CONVERT_ARG_CHECKED(String, type, 0); | 11740 CONVERT_ARG_CHECKED(String, type, 0); |
12051 CONVERT_ARG_CHECKED(JSArray, arguments, 1); | 11741 CONVERT_ARG_CHECKED(JSArray, arguments, 1); |
12052 return *isolate->factory()->NewJSMessageObject( | 11742 return *isolate->factory()->NewJSMessageObject( |
12053 type, | 11743 type, |
12054 arguments, | 11744 arguments, |
12055 0, | 11745 0, |
12056 0, | 11746 0, |
12057 isolate->factory()->undefined_value(), | 11747 isolate->factory()->undefined_value(), |
12058 isolate->factory()->undefined_value(), | 11748 isolate->factory()->undefined_value(), |
12059 isolate->factory()->undefined_value()); | 11749 isolate->factory()->undefined_value()); |
12060 } | 11750 } |
12061 | 11751 |
12062 | 11752 |
12063 static MaybeObject* Runtime_MessageGetType(RUNTIME_CALLING_CONVENTION) { | 11753 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetType) { |
12064 RUNTIME_GET_ISOLATE; | |
12065 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 11754 CONVERT_CHECKED(JSMessageObject, message, args[0]); |
12066 return message->type(); | 11755 return message->type(); |
12067 } | 11756 } |
12068 | 11757 |
12069 | 11758 |
12070 static MaybeObject* Runtime_MessageGetArguments(RUNTIME_CALLING_CONVENTION) { | 11759 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetArguments) { |
12071 RUNTIME_GET_ISOLATE; | |
12072 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 11760 CONVERT_CHECKED(JSMessageObject, message, args[0]); |
12073 return message->arguments(); | 11761 return message->arguments(); |
12074 } | 11762 } |
12075 | 11763 |
12076 | 11764 |
12077 static MaybeObject* Runtime_MessageGetStartPosition( | 11765 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { |
12078 RUNTIME_CALLING_CONVENTION) { | |
12079 RUNTIME_GET_ISOLATE; | |
12080 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 11766 CONVERT_CHECKED(JSMessageObject, message, args[0]); |
12081 return Smi::FromInt(message->start_position()); | 11767 return Smi::FromInt(message->start_position()); |
12082 } | 11768 } |
12083 | 11769 |
12084 | 11770 |
12085 static MaybeObject* Runtime_MessageGetScript(RUNTIME_CALLING_CONVENTION) { | 11771 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { |
12086 RUNTIME_GET_ISOLATE; | |
12087 CONVERT_CHECKED(JSMessageObject, message, args[0]); | 11772 CONVERT_CHECKED(JSMessageObject, message, args[0]); |
12088 return message->script(); | 11773 return message->script(); |
12089 } | 11774 } |
12090 | 11775 |
12091 | 11776 |
12092 #ifdef DEBUG | 11777 #ifdef DEBUG |
12093 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 11778 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
12094 // Exclude the code in release mode. | 11779 // Exclude the code in release mode. |
12095 static MaybeObject* Runtime_ListNatives(RUNTIME_CALLING_CONVENTION) { | 11780 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { |
12096 RUNTIME_GET_ISOLATE; | |
12097 ASSERT(args.length() == 0); | 11781 ASSERT(args.length() == 0); |
12098 HandleScope scope; | 11782 HandleScope scope; |
12099 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 11783 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
12100 int entry_count = 0 | 11784 int entry_count = 0 |
12101 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 11785 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
12102 INLINE_FUNCTION_LIST(COUNT_ENTRY) | 11786 INLINE_FUNCTION_LIST(COUNT_ENTRY) |
12103 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); | 11787 INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); |
12104 #undef COUNT_ENTRY | 11788 #undef COUNT_ENTRY |
12105 Factory* factory = isolate->factory(); | 11789 Factory* factory = isolate->factory(); |
12106 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 11790 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
(...skipping 23 matching lines...) Expand all Loading... |
12130 INLINE_FUNCTION_LIST(ADD_ENTRY) | 11814 INLINE_FUNCTION_LIST(ADD_ENTRY) |
12131 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) | 11815 INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
12132 #undef ADD_ENTRY | 11816 #undef ADD_ENTRY |
12133 ASSERT_EQ(index, entry_count); | 11817 ASSERT_EQ(index, entry_count); |
12134 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 11818 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
12135 return *result; | 11819 return *result; |
12136 } | 11820 } |
12137 #endif | 11821 #endif |
12138 | 11822 |
12139 | 11823 |
12140 static MaybeObject* Runtime_Log(RUNTIME_CALLING_CONVENTION) { | 11824 RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) { |
12141 RUNTIME_GET_ISOLATE; | |
12142 ASSERT(args.length() == 2); | 11825 ASSERT(args.length() == 2); |
12143 CONVERT_CHECKED(String, format, args[0]); | 11826 CONVERT_CHECKED(String, format, args[0]); |
12144 CONVERT_CHECKED(JSArray, elms, args[1]); | 11827 CONVERT_CHECKED(JSArray, elms, args[1]); |
12145 Vector<const char> chars = format->ToAsciiVector(); | 11828 Vector<const char> chars = format->ToAsciiVector(); |
12146 LOGGER->LogRuntime(chars, elms); | 11829 LOGGER->LogRuntime(chars, elms); |
12147 return isolate->heap()->undefined_value(); | 11830 return isolate->heap()->undefined_value(); |
12148 } | 11831 } |
12149 | 11832 |
12150 | 11833 |
12151 static MaybeObject* Runtime_IS_VAR(RUNTIME_CALLING_CONVENTION) { | 11834 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { |
12152 UNREACHABLE(); // implemented as macro in the parser | 11835 UNREACHABLE(); // implemented as macro in the parser |
12153 return NULL; | 11836 return NULL; |
12154 } | 11837 } |
12155 | 11838 |
12156 | 11839 |
12157 // ---------------------------------------------------------------------------- | 11840 // ---------------------------------------------------------------------------- |
12158 // Implementation of Runtime | 11841 // Implementation of Runtime |
12159 | 11842 |
12160 #define F(name, number_of_args, result_size) \ | 11843 #define F(name, number_of_args, result_size) \ |
12161 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 11844 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12227 } else { | 11910 } else { |
12228 // Handle last resort GC and make sure to allow future allocations | 11911 // Handle last resort GC and make sure to allow future allocations |
12229 // to grow the heap without causing GCs (if possible). | 11912 // to grow the heap without causing GCs (if possible). |
12230 isolate->counters()->gc_last_resort_from_js()->Increment(); | 11913 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12231 isolate->heap()->CollectAllGarbage(false); | 11914 isolate->heap()->CollectAllGarbage(false); |
12232 } | 11915 } |
12233 } | 11916 } |
12234 | 11917 |
12235 | 11918 |
12236 } } // namespace v8::internal | 11919 } } // namespace v8::internal |
OLD | NEW |