| OLD | NEW |
| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 isolate->counters()->array_function_runtime()->Increment(); | 202 isolate->counters()->array_function_runtime()->Increment(); |
| 203 | 203 |
| 204 JSArray* array; | 204 JSArray* array; |
| 205 if (CalledAsConstructor(isolate)) { | 205 if (CalledAsConstructor(isolate)) { |
| 206 array = JSArray::cast((*args)[0]); | 206 array = JSArray::cast((*args)[0]); |
| 207 // Initialize elements and length in case later allocations fail so that the | 207 // Initialize elements and length in case later allocations fail so that the |
| 208 // array object is initialized in a valid state. | 208 // array object is initialized in a valid state. |
| 209 MaybeObject* maybe_array = array->Initialize(0); | 209 MaybeObject* maybe_array = array->Initialize(0); |
| 210 if (maybe_array->IsFailure()) return maybe_array; | 210 if (maybe_array->IsFailure()) return maybe_array; |
| 211 | 211 |
| 212 if (FLAG_optimize_constructed_arrays) { | 212 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array); |
| 213 AllocationSiteInfo* info = AllocationSiteInfo::FindForJSObject(array); | 213 ElementsKind to_kind = array->GetElementsKind(); |
| 214 ElementsKind to_kind = array->GetElementsKind(); | 214 if (info != NULL && info->GetElementsKindPayload(&to_kind)) { |
| 215 if (info != NULL && info->GetElementsKindPayload(&to_kind)) { | 215 if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(), |
| 216 if (IsMoreGeneralElementsKindTransition(array->GetElementsKind(), | 216 to_kind)) { |
| 217 to_kind)) { | 217 // We have advice that we should change the elements kind |
| 218 // We have advice that we should change the elements kind | 218 if (FLAG_trace_track_allocation_sites) { |
| 219 if (FLAG_trace_track_allocation_sites) { | 219 PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n", |
| 220 PrintF("AllocationSiteInfo: pre-transitioning array %p(%s->%s)\n", | 220 reinterpret_cast<void*>(array), |
| 221 reinterpret_cast<void*>(array), | 221 ElementsKindToString(array->GetElementsKind()), |
| 222 ElementsKindToString(array->GetElementsKind()), | 222 ElementsKindToString(to_kind)); |
| 223 ElementsKindToString(to_kind)); | 223 } |
| 224 } | |
| 225 | 224 |
| 226 maybe_array = array->TransitionElementsKind(to_kind); | 225 maybe_array = array->TransitionElementsKind(to_kind); |
| 227 if (maybe_array->IsFailure()) return maybe_array; | 226 if (maybe_array->IsFailure()) return maybe_array; |
| 228 } | |
| 229 } | 227 } |
| 230 } | 228 } |
| 231 | 229 |
| 232 if (!FLAG_smi_only_arrays) { | 230 if (!FLAG_smi_only_arrays) { |
| 233 Context* native_context = isolate->context()->native_context(); | 231 Context* native_context = isolate->context()->native_context(); |
| 234 if (array->GetElementsKind() == GetInitialFastElementsKind() && | 232 if (array->GetElementsKind() == GetInitialFastElementsKind() && |
| 235 !native_context->js_array_maps()->IsUndefined()) { | 233 !native_context->js_array_maps()->IsUndefined()) { |
| 236 FixedArray* map_array = | 234 FixedArray* map_array = |
| 237 FixedArray::cast(native_context->js_array_maps()); | 235 FixedArray::cast(native_context->js_array_maps()); |
| 238 array->set_map(Map::cast(map_array-> | 236 array->set_map(Map::cast(map_array-> |
| (...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1260 ASSERT(raw_holder->IsJSObject()); | 1258 ASSERT(raw_holder->IsJSObject()); |
| 1261 | 1259 |
| 1262 FunctionCallbackArguments custom(isolate, | 1260 FunctionCallbackArguments custom(isolate, |
| 1263 data_obj, | 1261 data_obj, |
| 1264 *function, | 1262 *function, |
| 1265 raw_holder, | 1263 raw_holder, |
| 1266 &args[0] - 1, | 1264 &args[0] - 1, |
| 1267 args.length() - 1, | 1265 args.length() - 1, |
| 1268 is_construct); | 1266 is_construct); |
| 1269 | 1267 |
| 1270 v8::Handle<v8::Value> value; | 1268 v8::Handle<v8::Value> value = custom.Call(callback); |
| 1271 { | |
| 1272 // Leaving JavaScript. | |
| 1273 VMState<EXTERNAL> state(isolate); | |
| 1274 ExternalCallbackScope call_scope(isolate, | |
| 1275 v8::ToCData<Address>(callback_obj)); | |
| 1276 value = custom.Call(callback); | |
| 1277 } | |
| 1278 if (value.IsEmpty()) { | 1269 if (value.IsEmpty()) { |
| 1279 result = heap->undefined_value(); | 1270 result = heap->undefined_value(); |
| 1280 } else { | 1271 } else { |
| 1281 result = *reinterpret_cast<Object**>(*value); | 1272 result = *reinterpret_cast<Object**>(*value); |
| 1282 result->VerifyApiCallResultType(); | 1273 result->VerifyApiCallResultType(); |
| 1283 } | 1274 } |
| 1284 | 1275 |
| 1285 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1276 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1286 if (!is_construct || result->IsJSObject()) return result; | 1277 if (!is_construct || result->IsJSObject()) return result; |
| 1287 } | 1278 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 HandleScope scope(isolate); | 1327 HandleScope scope(isolate); |
| 1337 LOG(isolate, ApiObjectAccess("call non-function", obj)); | 1328 LOG(isolate, ApiObjectAccess("call non-function", obj)); |
| 1338 | 1329 |
| 1339 FunctionCallbackArguments custom(isolate, | 1330 FunctionCallbackArguments custom(isolate, |
| 1340 call_data->data(), | 1331 call_data->data(), |
| 1341 constructor, | 1332 constructor, |
| 1342 obj, | 1333 obj, |
| 1343 &args[0] - 1, | 1334 &args[0] - 1, |
| 1344 args.length() - 1, | 1335 args.length() - 1, |
| 1345 is_construct_call); | 1336 is_construct_call); |
| 1346 v8::Handle<v8::Value> value; | 1337 v8::Handle<v8::Value> value = custom.Call(callback); |
| 1347 { | |
| 1348 // Leaving JavaScript. | |
| 1349 VMState<EXTERNAL> state(isolate); | |
| 1350 ExternalCallbackScope call_scope(isolate, | |
| 1351 v8::ToCData<Address>(callback_obj)); | |
| 1352 value = custom.Call(callback); | |
| 1353 } | |
| 1354 if (value.IsEmpty()) { | 1338 if (value.IsEmpty()) { |
| 1355 result = heap->undefined_value(); | 1339 result = heap->undefined_value(); |
| 1356 } else { | 1340 } else { |
| 1357 result = *reinterpret_cast<Object**>(*value); | 1341 result = *reinterpret_cast<Object**>(*value); |
| 1358 result->VerifyApiCallResultType(); | 1342 result->VerifyApiCallResultType(); |
| 1359 } | 1343 } |
| 1360 } | 1344 } |
| 1361 // Check for exceptions and return result. | 1345 // Check for exceptions and return result. |
| 1362 RETURN_IF_SCHEDULED_EXCEPTION(isolate); | 1346 RETURN_IF_SCHEDULED_EXCEPTION(isolate); |
| 1363 return result; | 1347 return result; |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 return Handle<Code>(code_address); \ | 1826 return Handle<Code>(code_address); \ |
| 1843 } | 1827 } |
| 1844 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1828 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 1845 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1829 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1846 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1830 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 1847 #undef DEFINE_BUILTIN_ACCESSOR_C | 1831 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 1848 #undef DEFINE_BUILTIN_ACCESSOR_A | 1832 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 1849 | 1833 |
| 1850 | 1834 |
| 1851 } } // namespace v8::internal | 1835 } } // namespace v8::internal |
| OLD | NEW |