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

Side by Side Diff: src/accessors.cc

Issue 254783003: Convert function.name to API-style accessor and make CallApiGetterStub serializable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/arm/code-stubs-arm.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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 &FunctionLengthSetter, 940 &FunctionLengthSetter,
941 attributes); 941 attributes);
942 } 942 }
943 943
944 944
945 // 945 //
946 // Accessors::FunctionName 946 // Accessors::FunctionName
947 // 947 //
948 948
949 949
950 Object* Accessors::FunctionGetName(Isolate* isolate, 950 void Accessors::FunctionNameGetter(
951 Object* object, 951 v8::Local<v8::String> name,
952 void*) { 952 const v8::PropertyCallbackInfo<v8::Value>& info) {
953 JSFunction* holder = FindInstanceOf<JSFunction>(isolate, object); 953 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
954 return holder == NULL 954 HandleScope scope(isolate);
955 ? isolate->heap()->undefined_value() 955 Handle<Object> object = Utils::OpenHandle(*info.This());
956 : holder->shared()->name(); 956 MaybeHandle<JSFunction> maybe_function;
957
958 {
959 DisallowHeapAllocation no_allocation;
960 JSFunction* function = FindInstanceOf<JSFunction>(isolate, *object);
961 if (function != NULL) maybe_function = Handle<JSFunction>(function);
962 }
963
964 Handle<JSFunction> function;
965 Handle<Object> result;
966 if (maybe_function.ToHandle(&function)) {
967 result = Handle<Object>(function->shared()->name(), isolate);
968 } else {
969 result = isolate->factory()->undefined_value();
970 }
971 info.GetReturnValue().Set(Utils::ToLocal(result));
957 } 972 }
958 973
959 974
960 const AccessorDescriptor Accessors::FunctionName = { 975 void Accessors::FunctionNameSetter(
961 FunctionGetName, 976 v8::Local<v8::String> name,
962 ReadOnlySetAccessor, 977 v8::Local<v8::Value> val,
963 0 978 const v8::PropertyCallbackInfo<void>& info) {
964 }; 979 // Do nothing.
980 }
981
982
983 Handle<AccessorInfo> Accessors::FunctionNameInfo(
984 Isolate* isolate, PropertyAttributes attributes) {
985 return MakeAccessor(isolate,
986 isolate->factory()->name_string(),
987 &FunctionNameGetter,
988 &FunctionNameSetter,
989 attributes);
990 }
965 991
966 992
967 // 993 //
968 // Accessors::FunctionArguments 994 // Accessors::FunctionArguments
969 // 995 //
970 996
971 997
972 static Handle<Object> ArgumentsForInlinedFunction( 998 static Handle<Object> ArgumentsForInlinedFunction(
973 JavaScriptFrame* frame, 999 JavaScriptFrame* frame,
974 Handle<JSFunction> inlined_function, 1000 Handle<JSFunction> inlined_function,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 info->set_data(Smi::FromInt(index)); 1287 info->set_data(Smi::FromInt(index));
1262 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport); 1288 Handle<Object> getter = v8::FromCData(isolate, &ModuleGetExport);
1263 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport); 1289 Handle<Object> setter = v8::FromCData(isolate, &ModuleSetExport);
1264 info->set_getter(*getter); 1290 info->set_getter(*getter);
1265 if (!(attributes & ReadOnly)) info->set_setter(*setter); 1291 if (!(attributes & ReadOnly)) info->set_setter(*setter);
1266 return info; 1292 return info;
1267 } 1293 }
1268 1294
1269 1295
1270 } } // namespace v8::internal 1296 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/accessors.h ('k') | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698