Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: src/accessors.cc

Issue 236313015: Handlify and convert the remaining Script accesssors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 &ScriptLineOffsetSetter, 471 &ScriptLineOffsetSetter,
472 attributes); 472 attributes);
473 } 473 }
474 474
475 475
476 // 476 //
477 // Accessors::ScriptType 477 // Accessors::ScriptType
478 // 478 //
479 479
480 480
481 MaybeObject* Accessors::ScriptGetType(Isolate* isolate, 481 void Accessors::ScriptTypeGetter(
482 Object* object, 482 v8::Local<v8::String> name,
483 void*) { 483 const v8::PropertyCallbackInfo<v8::Value>& info) {
484 Object* script = JSValue::cast(object)->value(); 484 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
485 return Script::cast(script)->type(); 485 DisallowHeapAllocation no_allocation;
486 HandleScope scope(isolate);
487 Object* object = *Utils::OpenHandle(*info.This());
488 Object* res = Script::cast(JSValue::cast(object)->value())->type();
489 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
486 } 490 }
487 491
488 492
489 const AccessorDescriptor Accessors::ScriptType = { 493 void Accessors::ScriptTypeSetter(
490 ScriptGetType, 494 v8::Local<v8::String> name,
491 IllegalSetter, 495 v8::Local<v8::Value> value,
492 0 496 const v8::PropertyCallbackInfo<void>& info) {
493 }; 497 UNREACHABLE();
498 }
499
500
501 Handle<AccessorInfo> Accessors::ScriptTypeInfo(
502 Isolate* isolate, PropertyAttributes attributes) {
503 Handle<String> name(isolate->factory()->InternalizeOneByteString(
504 STATIC_ASCII_VECTOR("type")));
505 return MakeAccessor(isolate,
506 name,
507 &ScriptTypeGetter,
508 &ScriptTypeSetter,
509 attributes);
510 }
494 511
495 512
496 // 513 //
497 // Accessors::ScriptCompilationType 514 // Accessors::ScriptCompilationType
498 // 515 //
499 516
500 517
501 MaybeObject* Accessors::ScriptGetCompilationType(Isolate* isolate, 518 void Accessors::ScriptCompilationTypeGetter(
502 Object* object, 519 v8::Local<v8::String> name,
503 void*) { 520 const v8::PropertyCallbackInfo<v8::Value>& info) {
504 Object* script = JSValue::cast(object)->value(); 521 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
505 return Smi::FromInt(Script::cast(script)->compilation_type()); 522 DisallowHeapAllocation no_allocation;
523 HandleScope scope(isolate);
524 Object* object = *Utils::OpenHandle(*info.This());
525 Object* res = Smi::FromInt(
526 Script::cast(JSValue::cast(object)->value())->compilation_type());
527 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
506 } 528 }
507 529
508 530
509 const AccessorDescriptor Accessors::ScriptCompilationType = { 531 void Accessors::ScriptCompilationTypeSetter(
510 ScriptGetCompilationType, 532 v8::Local<v8::String> name,
511 IllegalSetter, 533 v8::Local<v8::Value> value,
512 0 534 const v8::PropertyCallbackInfo<void>& info) {
513 }; 535 UNREACHABLE();
536 }
537
538
539 Handle<AccessorInfo> Accessors::ScriptCompilationTypeInfo(
540 Isolate* isolate, PropertyAttributes attributes) {
541 Handle<String> name(isolate->factory()->InternalizeOneByteString(
542 STATIC_ASCII_VECTOR("compilation_type")));
543 return MakeAccessor(isolate,
544 name,
545 &ScriptCompilationTypeGetter,
546 &ScriptCompilationTypeSetter,
547 attributes);
548 }
514 549
515 550
516 // 551 //
517 // Accessors::ScriptGetLineEnds 552 // Accessors::ScriptGetLineEnds
518 // 553 //
519 554
520 555
521 MaybeObject* Accessors::ScriptGetLineEnds(Isolate* isolate, 556 void Accessors::ScriptLineEndsGetter(
522 Object* object, 557 v8::Local<v8::String> name,
523 void*) { 558 const v8::PropertyCallbackInfo<v8::Value>& info) {
524 JSValue* wrapper = JSValue::cast(object); 559 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
525 HandleScope scope(isolate); 560 HandleScope scope(isolate);
526 Handle<Script> script(Script::cast(wrapper->value()), isolate); 561 Handle<Object> object = Utils::OpenHandle(*info.This());
562 Handle<Script> script(
563 Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
527 InitScriptLineEnds(script); 564 InitScriptLineEnds(script);
528 ASSERT(script->line_ends()->IsFixedArray()); 565 ASSERT(script->line_ends()->IsFixedArray());
529 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 566 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
530 // We do not want anyone to modify this array from JS. 567 // We do not want anyone to modify this array from JS.
531 ASSERT(*line_ends == isolate->heap()->empty_fixed_array() || 568 ASSERT(*line_ends == isolate->heap()->empty_fixed_array() ||
532 line_ends->map() == isolate->heap()->fixed_cow_array_map()); 569 line_ends->map() == isolate->heap()->fixed_cow_array_map());
533 Handle<JSArray> js_array = 570 Handle<JSArray> js_array =
534 isolate->factory()->NewJSArrayWithElements(line_ends); 571 isolate->factory()->NewJSArrayWithElements(line_ends);
535 return *js_array; 572 info.GetReturnValue().Set(Utils::ToLocal(js_array));
536 } 573 }
537 574
538 575
539 const AccessorDescriptor Accessors::ScriptLineEnds = { 576 void Accessors::ScriptLineEndsSetter(
540 ScriptGetLineEnds, 577 v8::Local<v8::String> name,
541 IllegalSetter, 578 v8::Local<v8::Value> value,
542 0 579 const v8::PropertyCallbackInfo<void>& info) {
543 }; 580 UNREACHABLE();
581 }
582
583
584 Handle<AccessorInfo> Accessors::ScriptLineEndsInfo(
585 Isolate* isolate, PropertyAttributes attributes) {
586 Handle<String> name(isolate->factory()->InternalizeOneByteString(
587 STATIC_ASCII_VECTOR("line_ends")));
588 return MakeAccessor(isolate,
589 name,
590 &ScriptLineEndsGetter,
591 &ScriptLineEndsSetter,
592 attributes);
593 }
544 594
545 595
546 // 596 //
547 // Accessors::ScriptGetContextData 597 // Accessors::ScriptGetContextData
548 // 598 //
549 599
550 600
551 MaybeObject* Accessors::ScriptGetContextData(Isolate* isolate, 601 void Accessors::ScriptContextDataGetter(
552 Object* object, 602 v8::Local<v8::String> name,
553 void*) { 603 const v8::PropertyCallbackInfo<v8::Value>& info) {
554 Object* script = JSValue::cast(object)->value(); 604 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
555 return Script::cast(script)->context_data(); 605 DisallowHeapAllocation no_allocation;
606 HandleScope scope(isolate);
607 Object* object = *Utils::OpenHandle(*info.This());
608 Object* res = Script::cast(JSValue::cast(object)->value())->context_data();
609 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(res, isolate)));
556 } 610 }
557 611
558 612
559 const AccessorDescriptor Accessors::ScriptContextData = { 613 void Accessors::ScriptContextDataSetter(
560 ScriptGetContextData, 614 v8::Local<v8::String> name,
561 IllegalSetter, 615 v8::Local<v8::Value> value,
562 0 616 const v8::PropertyCallbackInfo<void>& info) {
563 }; 617 UNREACHABLE();
618 }
619
620
621 Handle<AccessorInfo> Accessors::ScriptContextDataInfo(
622 Isolate* isolate, PropertyAttributes attributes) {
623 Handle<String> name(isolate->factory()->InternalizeOneByteString(
624 STATIC_ASCII_VECTOR("context_data")));
625 return MakeAccessor(isolate,
626 name,
627 &ScriptContextDataGetter,
628 &ScriptContextDataSetter,
629 attributes);
630 }
564 631
565 632
566 // 633 //
567 // Accessors::ScriptGetEvalFromScript 634 // Accessors::ScriptGetEvalFromScript
568 // 635 //
569 636
570 637
571 MaybeObject* Accessors::ScriptGetEvalFromScript(Isolate* isolate, 638 void Accessors::ScriptEvalFromScriptGetter(
572 Object* object, 639 v8::Local<v8::String> name,
573 void*) { 640 const v8::PropertyCallbackInfo<v8::Value>& info) {
574 Object* script = JSValue::cast(object)->value(); 641 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
575 if (!Script::cast(script)->eval_from_shared()->IsUndefined()) { 642 HandleScope scope(isolate);
643 Handle<Object> object = Utils::OpenHandle(*info.This());
644 Handle<Script> script(
645 Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
646 Handle<Object> result = isolate->factory()->undefined_value();
647 if (!script->eval_from_shared()->IsUndefined()) {
576 Handle<SharedFunctionInfo> eval_from_shared( 648 Handle<SharedFunctionInfo> eval_from_shared(
577 SharedFunctionInfo::cast(Script::cast(script)->eval_from_shared())); 649 SharedFunctionInfo::cast(script->eval_from_shared()));
578
579 if (eval_from_shared->script()->IsScript()) { 650 if (eval_from_shared->script()->IsScript()) {
580 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script())); 651 Handle<Script> eval_from_script(Script::cast(eval_from_shared->script()));
581 return *GetScriptWrapper(eval_from_script); 652 result = GetScriptWrapper(eval_from_script);
582 } 653 }
583 } 654 }
584 return isolate->heap()->undefined_value(); 655
656 info.GetReturnValue().Set(Utils::ToLocal(result));
585 } 657 }
586 658
587 659
588 const AccessorDescriptor Accessors::ScriptEvalFromScript = { 660 void Accessors::ScriptEvalFromScriptSetter(
589 ScriptGetEvalFromScript, 661 v8::Local<v8::String> name,
590 IllegalSetter, 662 v8::Local<v8::Value> value,
591 0 663 const v8::PropertyCallbackInfo<void>& info) {
592 }; 664 UNREACHABLE();
665 }
666
667
668 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptInfo(
669 Isolate* isolate, PropertyAttributes attributes) {
670 Handle<String> name(isolate->factory()->InternalizeOneByteString(
671 STATIC_ASCII_VECTOR("eval_from_script")));
672 return MakeAccessor(isolate,
673 name,
674 &ScriptEvalFromScriptGetter,
675 &ScriptEvalFromScriptSetter,
676 attributes);
677 }
593 678
594 679
595 // 680 //
596 // Accessors::ScriptGetEvalFromScriptPosition 681 // Accessors::ScriptGetEvalFromScriptPosition
597 // 682 //
598 683
599 684
600 MaybeObject* Accessors::ScriptGetEvalFromScriptPosition(Isolate* isolate, 685 void Accessors::ScriptEvalFromScriptPositionGetter(
601 Object* object, 686 v8::Local<v8::String> name,
602 void*) { 687 const v8::PropertyCallbackInfo<v8::Value>& info) {
603 Script* raw_script = Script::cast(JSValue::cast(object)->value()); 688 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
604 HandleScope scope(isolate); 689 HandleScope scope(isolate);
605 Handle<Script> script(raw_script); 690 Handle<Object> object = Utils::OpenHandle(*info.This());
606 691 Handle<Script> script(
607 // If this is not a script compiled through eval there is no eval position. 692 Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
608 if (script->compilation_type() != Script::COMPILATION_TYPE_EVAL) { 693 Handle<Object> result = isolate->factory()->undefined_value();
609 return script->GetHeap()->undefined_value(); 694 if (script->compilation_type() == Script::COMPILATION_TYPE_EVAL) {
695 Handle<Code> code(SharedFunctionInfo::cast(
696 script->eval_from_shared())->code());
697 result = Handle<Object>(
698 Smi::FromInt(code->SourcePosition(code->instruction_start() +
699 script->eval_from_instructions_offset()->value())),
700 isolate);
610 } 701 }
611 702 info.GetReturnValue().Set(Utils::ToLocal(result));
612 // Get the function from where eval was called and find the source position
613 // from the instruction offset.
614 Handle<Code> code(SharedFunctionInfo::cast(
615 script->eval_from_shared())->code());
616 return Smi::FromInt(code->SourcePosition(code->instruction_start() +
617 script->eval_from_instructions_offset()->value()));
618 } 703 }
619 704
620 705
621 const AccessorDescriptor Accessors::ScriptEvalFromScriptPosition = { 706 void Accessors::ScriptEvalFromScriptPositionSetter(
622 ScriptGetEvalFromScriptPosition, 707 v8::Local<v8::String> name,
623 IllegalSetter, 708 v8::Local<v8::Value> value,
624 0 709 const v8::PropertyCallbackInfo<void>& info) {
625 }; 710 UNREACHABLE();
711 }
712
713
714 Handle<AccessorInfo> Accessors::ScriptEvalFromScriptPositionInfo(
715 Isolate* isolate, PropertyAttributes attributes) {
716 Handle<String> name(isolate->factory()->InternalizeOneByteString(
717 STATIC_ASCII_VECTOR("eval_from_script_position")));
718 return MakeAccessor(isolate,
719 name,
720 &ScriptEvalFromScriptPositionGetter,
721 &ScriptEvalFromScriptPositionSetter,
722 attributes);
723 }
626 724
627 725
628 // 726 //
629 // Accessors::ScriptGetEvalFromFunctionName 727 // Accessors::ScriptGetEvalFromFunctionName
630 // 728 //
631 729
632 730
633 MaybeObject* Accessors::ScriptGetEvalFromFunctionName(Isolate* isolate, 731 void Accessors::ScriptEvalFromFunctionNameGetter(
634 Object* object, 732 v8::Local<v8::String> name,
635 void*) { 733 const v8::PropertyCallbackInfo<v8::Value>& info) {
636 Object* script = JSValue::cast(object)->value(); 734 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
637 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast( 735 HandleScope scope(isolate);
638 Script::cast(script)->eval_from_shared())); 736 Handle<Object> object = Utils::OpenHandle(*info.This());
639 737 Handle<Script> script(
640 738 Script::cast(Handle<JSValue>::cast(object)->value()), isolate);
739 Handle<Object> result;
740 Handle<SharedFunctionInfo> shared(
741 SharedFunctionInfo::cast(script->eval_from_shared()));
641 // Find the name of the function calling eval. 742 // Find the name of the function calling eval.
642 if (!shared->name()->IsUndefined()) { 743 if (!shared->name()->IsUndefined()) {
643 return shared->name(); 744 result = Handle<Object>(shared->name(), isolate);
644 } else { 745 } else {
645 return shared->inferred_name(); 746 result = Handle<Object>(shared->inferred_name(), isolate);
646 } 747 }
748 info.GetReturnValue().Set(Utils::ToLocal(result));
647 } 749 }
648 750
649 751
650 const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = { 752 void Accessors::ScriptEvalFromFunctionNameSetter(
651 ScriptGetEvalFromFunctionName, 753 v8::Local<v8::String> name,
652 IllegalSetter, 754 v8::Local<v8::Value> value,
653 0 755 const v8::PropertyCallbackInfo<void>& info) {
654 }; 756 UNREACHABLE();
757 }
758
759
760 Handle<AccessorInfo> Accessors::ScriptEvalFromFunctionNameInfo(
761 Isolate* isolate, PropertyAttributes attributes) {
762 Handle<String> name(isolate->factory()->InternalizeOneByteString(
763 STATIC_ASCII_VECTOR("eval_from_function_name")));
764 return MakeAccessor(isolate,
765 name,
766 &ScriptEvalFromFunctionNameGetter,
767 &ScriptEvalFromFunctionNameSetter,
768 attributes);
769 }
655 770
656 771
657 // 772 //
658 // Accessors::FunctionPrototype 773 // Accessors::FunctionPrototype
659 // 774 //
660 775
661 776
662 Handle<Object> Accessors::FunctionGetPrototype(Handle<JSFunction> function) { 777 Handle<Object> Accessors::FunctionGetPrototype(Handle<JSFunction> function) {
663 CALL_HEAP_FUNCTION(function->GetIsolate(), 778 CALL_HEAP_FUNCTION(function->GetIsolate(),
664 Accessors::FunctionGetPrototype(function->GetIsolate(), 779 Accessors::FunctionGetPrototype(function->GetIsolate(),
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 info->set_data(Smi::FromInt(index)); 1205 info->set_data(Smi::FromInt(index));
1091 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1206 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1092 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1207 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1093 info->set_getter(*getter); 1208 info->set_getter(*getter);
1094 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1209 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1095 return info; 1210 return info;
1096 } 1211 }
1097 1212
1098 1213
1099 } } // namespace v8::internal 1214 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698