OLD | NEW |
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // | 145 // |
146 // Accessors::ArrayLength | 146 // Accessors::ArrayLength |
147 // | 147 // |
148 | 148 |
149 | 149 |
150 void Accessors::ArrayLengthGetter( | 150 void Accessors::ArrayLengthGetter( |
151 v8::Local<v8::Name> name, | 151 v8::Local<v8::Name> name, |
152 const v8::PropertyCallbackInfo<v8::Value>& info) { | 152 const v8::PropertyCallbackInfo<v8::Value>& info) { |
153 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 153 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 154 RuntimeCallTimerScope timer( |
| 155 isolate, &RuntimeCallStats::AccessorNameGetterCallback_ArrayLength); |
154 DisallowHeapAllocation no_allocation; | 156 DisallowHeapAllocation no_allocation; |
155 HandleScope scope(isolate); | 157 HandleScope scope(isolate); |
156 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); | 158 JSArray* holder = JSArray::cast(*Utils::OpenHandle(*info.Holder())); |
157 Object* result = holder->length(); | 159 Object* result = holder->length(); |
158 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); | 160 info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate))); |
159 } | 161 } |
160 | 162 |
161 | 163 |
162 void Accessors::ArrayLengthSetter( | 164 void Accessors::ArrayLengthSetter( |
163 v8::Local<v8::Name> name, | 165 v8::Local<v8::Name> name, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 250 |
249 | 251 |
250 // | 252 // |
251 // Accessors::StringLength | 253 // Accessors::StringLength |
252 // | 254 // |
253 | 255 |
254 void Accessors::StringLengthGetter( | 256 void Accessors::StringLengthGetter( |
255 v8::Local<v8::Name> name, | 257 v8::Local<v8::Name> name, |
256 const v8::PropertyCallbackInfo<v8::Value>& info) { | 258 const v8::PropertyCallbackInfo<v8::Value>& info) { |
257 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 259 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 260 RuntimeCallTimerScope timer( |
| 261 isolate, &RuntimeCallStats::AccessorNameGetterCallback_StringLength); |
258 DisallowHeapAllocation no_allocation; | 262 DisallowHeapAllocation no_allocation; |
259 HandleScope scope(isolate); | 263 HandleScope scope(isolate); |
260 | 264 |
261 // We have a slight impedance mismatch between the external API and the way we | 265 // We have a slight impedance mismatch between the external API and the way we |
262 // use callbacks internally: Externally, callbacks can only be used with | 266 // use callbacks internally: Externally, callbacks can only be used with |
263 // v8::Object, but internally we have callbacks on entities which are higher | 267 // v8::Object, but internally we have callbacks on entities which are higher |
264 // in the hierarchy, in this case for String values. | 268 // in the hierarchy, in this case for String values. |
265 | 269 |
266 Object* value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); | 270 Object* value = *Utils::OpenHandle(*v8::Local<v8::Value>(info.This())); |
267 if (!value->IsString()) { | 271 if (!value->IsString()) { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 DCHECK(function->IsConstructor()); | 732 DCHECK(function->IsConstructor()); |
729 Isolate* isolate = function->GetIsolate(); | 733 Isolate* isolate = function->GetIsolate(); |
730 return SetFunctionPrototype(isolate, function, prototype); | 734 return SetFunctionPrototype(isolate, function, prototype); |
731 } | 735 } |
732 | 736 |
733 | 737 |
734 void Accessors::FunctionPrototypeGetter( | 738 void Accessors::FunctionPrototypeGetter( |
735 v8::Local<v8::Name> name, | 739 v8::Local<v8::Name> name, |
736 const v8::PropertyCallbackInfo<v8::Value>& info) { | 740 const v8::PropertyCallbackInfo<v8::Value>& info) { |
737 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 741 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 742 RuntimeCallTimerScope timer( |
| 743 isolate, &RuntimeCallStats::AccessorNameGetterCallback_FunctionPrototype); |
738 HandleScope scope(isolate); | 744 HandleScope scope(isolate); |
739 Handle<JSFunction> function = | 745 Handle<JSFunction> function = |
740 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); | 746 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); |
741 Handle<Object> result = GetFunctionPrototype(isolate, function); | 747 Handle<Object> result = GetFunctionPrototype(isolate, function); |
742 info.GetReturnValue().Set(Utils::ToLocal(result)); | 748 info.GetReturnValue().Set(Utils::ToLocal(result)); |
743 } | 749 } |
744 | 750 |
745 | 751 |
746 void Accessors::FunctionPrototypeSetter( | 752 void Accessors::FunctionPrototypeSetter( |
747 v8::Local<v8::Name> name, | 753 v8::Local<v8::Name> name, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 } | 1107 } |
1102 | 1108 |
1103 | 1109 |
1104 // | 1110 // |
1105 // Accessors::BoundFunctionLength | 1111 // Accessors::BoundFunctionLength |
1106 // | 1112 // |
1107 | 1113 |
1108 void Accessors::BoundFunctionLengthGetter( | 1114 void Accessors::BoundFunctionLengthGetter( |
1109 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 1115 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
1110 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1116 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1117 RuntimeCallTimerScope timer( |
| 1118 isolate, |
| 1119 &RuntimeCallStats::AccessorNameGetterCallback_BoundFunctionLength); |
1111 HandleScope scope(isolate); | 1120 HandleScope scope(isolate); |
1112 Handle<JSBoundFunction> function = | 1121 Handle<JSBoundFunction> function = |
1113 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1122 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); |
1114 | 1123 |
1115 Handle<Smi> target_length; | 1124 Handle<Smi> target_length; |
1116 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), | 1125 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), |
1117 isolate); | 1126 isolate); |
1118 if (!JSFunction::GetLength(isolate, target).ToHandle(&target_length)) { | 1127 if (!JSFunction::GetLength(isolate, target).ToHandle(&target_length)) { |
1119 target_length = handle(Smi::kZero, isolate); | 1128 target_length = handle(Smi::kZero, isolate); |
1120 isolate->OptionalRescheduleException(false); | 1129 isolate->OptionalRescheduleException(false); |
(...skipping 14 matching lines...) Expand all Loading... |
1135 attributes); | 1144 attributes); |
1136 } | 1145 } |
1137 | 1146 |
1138 // | 1147 // |
1139 // Accessors::BoundFunctionName | 1148 // Accessors::BoundFunctionName |
1140 // | 1149 // |
1141 | 1150 |
1142 void Accessors::BoundFunctionNameGetter( | 1151 void Accessors::BoundFunctionNameGetter( |
1143 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { | 1152 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { |
1144 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); | 1153 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); |
| 1154 RuntimeCallTimerScope timer( |
| 1155 isolate, &RuntimeCallStats::AccessorNameGetterCallback_BoundFunctionName); |
1145 HandleScope scope(isolate); | 1156 HandleScope scope(isolate); |
1146 Handle<JSBoundFunction> function = | 1157 Handle<JSBoundFunction> function = |
1147 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); | 1158 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); |
1148 Handle<Object> result; | 1159 Handle<Object> result; |
1149 if (!JSBoundFunction::GetName(isolate, function).ToHandle(&result)) { | 1160 if (!JSBoundFunction::GetName(isolate, function).ToHandle(&result)) { |
1150 isolate->OptionalRescheduleException(false); | 1161 isolate->OptionalRescheduleException(false); |
1151 return; | 1162 return; |
1152 } | 1163 } |
1153 info.GetReturnValue().Set(Utils::ToLocal(result)); | 1164 info.GetReturnValue().Set(Utils::ToLocal(result)); |
1154 } | 1165 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, | 1282 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, |
1272 PropertyAttributes attributes) { | 1283 PropertyAttributes attributes) { |
1273 Handle<AccessorInfo> info = | 1284 Handle<AccessorInfo> info = |
1274 MakeAccessor(isolate, isolate->factory()->stack_string(), | 1285 MakeAccessor(isolate, isolate->factory()->stack_string(), |
1275 &ErrorStackGetter, &ErrorStackSetter, attributes); | 1286 &ErrorStackGetter, &ErrorStackSetter, attributes); |
1276 return info; | 1287 return info; |
1277 } | 1288 } |
1278 | 1289 |
1279 } // namespace internal | 1290 } // namespace internal |
1280 } // namespace v8 | 1291 } // namespace v8 |
OLD | NEW |