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

Side by Side Diff: src/accessors.cc

Issue 2099983004: Revert of Refactor CreateApiFunction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | src/api-natives.h » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 STATIC_CHAR_VECTOR("eval_from_function_name"))); 657 STATIC_CHAR_VECTOR("eval_from_function_name")));
658 return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr, 658 return MakeAccessor(isolate, name, &ScriptEvalFromFunctionNameGetter, nullptr,
659 attributes); 659 attributes);
660 } 660 }
661 661
662 662
663 // 663 //
664 // Accessors::FunctionPrototype 664 // Accessors::FunctionPrototype
665 // 665 //
666 666
667 MaybeHandle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function, 667 static Handle<Object> GetFunctionPrototype(Isolate* isolate,
668 Handle<Object> prototype) { 668 Handle<JSFunction> function) {
669 JSFunction::SetPrototype(function, prototype); 669 if (!function->has_prototype()) {
670 Handle<Object> proto = isolate->factory()->NewFunctionPrototype(function);
671 JSFunction::SetPrototype(function, proto);
672 }
673 return Handle<Object>(function->prototype(), isolate);
674 }
675
676
677 MUST_USE_RESULT static MaybeHandle<Object> SetFunctionPrototype(
678 Isolate* isolate, Handle<JSFunction> function, Handle<Object> value) {
679 JSFunction::SetPrototype(function, value);
680 DCHECK(function->prototype() == *value);
670 return function; 681 return function;
671 } 682 }
672 683
673 684
685 MaybeHandle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function,
686 Handle<Object> prototype) {
687 DCHECK(function->IsConstructor());
688 Isolate* isolate = function->GetIsolate();
689 return SetFunctionPrototype(isolate, function, prototype);
690 }
691
692
674 void Accessors::FunctionPrototypeGetter( 693 void Accessors::FunctionPrototypeGetter(
675 v8::Local<v8::Name> name, 694 v8::Local<v8::Name> name,
676 const v8::PropertyCallbackInfo<v8::Value>& info) { 695 const v8::PropertyCallbackInfo<v8::Value>& info) {
677 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 696 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
678 HandleScope scope(isolate); 697 HandleScope scope(isolate);
679 Handle<JSFunction> function = 698 Handle<JSFunction> function =
680 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); 699 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
681 Handle<Object> result = JSFunction::GetPrototype(isolate, function); 700 Handle<Object> result = GetFunctionPrototype(isolate, function);
682 info.GetReturnValue().Set(Utils::ToLocal(result)); 701 info.GetReturnValue().Set(Utils::ToLocal(result));
683 } 702 }
684 703
685 704
686 void Accessors::FunctionPrototypeSetter( 705 void Accessors::FunctionPrototypeSetter(
687 v8::Local<v8::Name> name, 706 v8::Local<v8::Name> name,
688 v8::Local<v8::Value> val, 707 v8::Local<v8::Value> val,
689 const v8::PropertyCallbackInfo<void>& info) { 708 const v8::PropertyCallbackInfo<void>& info) {
690 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 709 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
691 HandleScope scope(isolate); 710 HandleScope scope(isolate);
692 Handle<Object> value = Utils::OpenHandle(*val); 711 Handle<Object> value = Utils::OpenHandle(*val);
693 Handle<JSFunction> object = 712 Handle<JSFunction> object =
694 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); 713 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
695 JSFunction::SetPrototype(object, value); 714 if (SetFunctionPrototype(isolate, object, value).is_null()) {
715 isolate->OptionalRescheduleException(false);
716 }
696 } 717 }
697 718
698 719
699 Handle<AccessorInfo> Accessors::FunctionPrototypeInfo( 720 Handle<AccessorInfo> Accessors::FunctionPrototypeInfo(
700 Isolate* isolate, PropertyAttributes attributes) { 721 Isolate* isolate, PropertyAttributes attributes) {
701 return MakeAccessor(isolate, 722 return MakeAccessor(isolate,
702 isolate->factory()->prototype_string(), 723 isolate->factory()->prototype_string(),
703 &FunctionPrototypeGetter, 724 &FunctionPrototypeGetter,
704 &FunctionPrototypeSetter, 725 &FunctionPrototypeSetter,
705 attributes); 726 attributes);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 Isolate* isolate = name->GetIsolate(); 1163 Isolate* isolate = name->GetIsolate();
1143 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport, 1164 Handle<AccessorInfo> info = MakeAccessor(isolate, name, &ModuleGetExport,
1144 &ModuleSetExport, attributes); 1165 &ModuleSetExport, attributes);
1145 info->set_data(Smi::FromInt(index)); 1166 info->set_data(Smi::FromInt(index));
1146 return info; 1167 return info;
1147 } 1168 }
1148 1169
1149 1170
1150 } // namespace internal 1171 } // namespace internal
1151 } // namespace v8 1172 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/api-natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698