| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 Handle<Object> value(constant_properties->get(index+1), isolate); | 258 Handle<Object> value(constant_properties->get(index+1), isolate); |
| 259 if (value->IsFixedArray()) { | 259 if (value->IsFixedArray()) { |
| 260 // The value contains the constant_properties of a | 260 // The value contains the constant_properties of a |
| 261 // simple object or array literal. | 261 // simple object or array literal. |
| 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
| 263 value = CreateLiteralBoilerplate(isolate, literals, array); | 263 value = CreateLiteralBoilerplate(isolate, literals, array); |
| 264 if (value.is_null()) return value; | 264 if (value.is_null()) return value; |
| 265 } | 265 } |
| 266 Handle<Object> result; | 266 Handle<Object> result; |
| 267 uint32_t element_index = 0; | 267 uint32_t element_index = 0; |
| 268 JSReceiver::StoreMode mode = value->IsJSObject() |
| 269 ? JSReceiver::FORCE_FIELD |
| 270 : JSReceiver::ALLOW_AS_CONSTANT; |
| 268 if (key->IsInternalizedString()) { | 271 if (key->IsInternalizedString()) { |
| 269 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 272 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
| 270 // Array index as string (uint32). | 273 // Array index as string (uint32). |
| 271 result = JSObject::SetOwnElement( | 274 result = JSObject::SetOwnElement( |
| 272 boilerplate, element_index, value, kNonStrictMode); | 275 boilerplate, element_index, value, kNonStrictMode); |
| 273 } else { | 276 } else { |
| 274 Handle<String> name(String::cast(*key)); | 277 Handle<String> name(String::cast(*key)); |
| 275 ASSERT(!name->AsArrayIndex(&element_index)); | 278 ASSERT(!name->AsArrayIndex(&element_index)); |
| 276 result = JSObject::SetLocalPropertyIgnoreAttributes( | 279 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 277 boilerplate, name, value, NONE); | 280 boilerplate, name, value, NONE, |
| 281 Object::OPTIMAL_REPRESENTATION, mode); |
| 278 } | 282 } |
| 279 } else if (key->ToArrayIndex(&element_index)) { | 283 } else if (key->ToArrayIndex(&element_index)) { |
| 280 // Array index (uint32). | 284 // Array index (uint32). |
| 281 result = JSObject::SetOwnElement( | 285 result = JSObject::SetOwnElement( |
| 282 boilerplate, element_index, value, kNonStrictMode); | 286 boilerplate, element_index, value, kNonStrictMode); |
| 283 } else { | 287 } else { |
| 284 // Non-uint32 number. | 288 // Non-uint32 number. |
| 285 ASSERT(key->IsNumber()); | 289 ASSERT(key->IsNumber()); |
| 286 double num = key->Number(); | 290 double num = key->Number(); |
| 287 char arr[100]; | 291 char arr[100]; |
| 288 Vector<char> buffer(arr, ARRAY_SIZE(arr)); | 292 Vector<char> buffer(arr, ARRAY_SIZE(arr)); |
| 289 const char* str = DoubleToCString(num, buffer); | 293 const char* str = DoubleToCString(num, buffer); |
| 290 Handle<String> name = | 294 Handle<String> name = |
| 291 isolate->factory()->NewStringFromAscii(CStrVector(str)); | 295 isolate->factory()->NewStringFromAscii(CStrVector(str)); |
| 292 result = JSObject::SetLocalPropertyIgnoreAttributes( | 296 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 293 boilerplate, name, value, NONE); | 297 boilerplate, name, value, NONE, |
| 298 Object::OPTIMAL_REPRESENTATION, mode); |
| 294 } | 299 } |
| 295 // If setting the property on the boilerplate throws an | 300 // If setting the property on the boilerplate throws an |
| 296 // exception, the exception is converted to an empty handle in | 301 // exception, the exception is converted to an empty handle in |
| 297 // the handle based operations. In that case, we need to | 302 // the handle based operations. In that case, we need to |
| 298 // convert back to an exception. | 303 // convert back to an exception. |
| 299 if (result.is_null()) return result; | 304 if (result.is_null()) return result; |
| 300 } | 305 } |
| 301 | 306 |
| 302 // Transform to fast properties if necessary. For object literals with | 307 // Transform to fast properties if necessary. For object literals with |
| 303 // containing function literals we defer this operation until after all | 308 // containing function literals we defer this operation until after all |
| (...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 properties->set(index, *value); | 2201 properties->set(index, *value); |
| 2197 } | 2202 } |
| 2198 } else if (lookup.IsNormal()) { | 2203 } else if (lookup.IsNormal()) { |
| 2199 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || | 2204 if (global->GetNormalizedProperty(&lookup)->IsTheHole() || |
| 2200 !lookup.IsReadOnly()) { | 2205 !lookup.IsReadOnly()) { |
| 2201 HandleScope scope(isolate); | 2206 HandleScope scope(isolate); |
| 2202 JSObject::SetNormalizedProperty(Handle<JSObject>(global), &lookup, value); | 2207 JSObject::SetNormalizedProperty(Handle<JSObject>(global), &lookup, value); |
| 2203 } | 2208 } |
| 2204 } else { | 2209 } else { |
| 2205 // Ignore re-initialization of constants that have already been | 2210 // Ignore re-initialization of constants that have already been |
| 2206 // assigned a function value. | 2211 // assigned a constant value. |
| 2207 ASSERT(lookup.IsReadOnly() && lookup.IsConstantFunction()); | 2212 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); |
| 2208 } | 2213 } |
| 2209 | 2214 |
| 2210 // Use the set value as the result of the operation. | 2215 // Use the set value as the result of the operation. |
| 2211 return *value; | 2216 return *value; |
| 2212 } | 2217 } |
| 2213 | 2218 |
| 2214 | 2219 |
| 2215 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) { | 2220 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeConstContextSlot) { |
| 2216 HandleScope scope(isolate); | 2221 HandleScope scope(isolate); |
| 2217 ASSERT(args.length() == 3); | 2222 ASSERT(args.length() == 3); |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2936 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) { | 2941 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResumeJSGeneratorObject) { |
| 2937 SealHandleScope shs(isolate); | 2942 SealHandleScope shs(isolate); |
| 2938 ASSERT(args.length() == 3); | 2943 ASSERT(args.length() == 3); |
| 2939 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 2944 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
| 2940 CONVERT_ARG_CHECKED(Object, value, 1); | 2945 CONVERT_ARG_CHECKED(Object, value, 1); |
| 2941 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 2946 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
| 2942 JavaScriptFrameIterator stack_iterator(isolate); | 2947 JavaScriptFrameIterator stack_iterator(isolate); |
| 2943 JavaScriptFrame* frame = stack_iterator.frame(); | 2948 JavaScriptFrame* frame = stack_iterator.frame(); |
| 2944 | 2949 |
| 2945 ASSERT_EQ(frame->function(), generator_object->function()); | 2950 ASSERT_EQ(frame->function(), generator_object->function()); |
| 2951 ASSERT(frame->function()->is_compiled()); |
| 2946 | 2952 |
| 2947 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); | 2953 STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); |
| 2948 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0); | 2954 STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0); |
| 2949 | 2955 |
| 2950 Address pc = generator_object->function()->code()->instruction_start(); | 2956 Address pc = generator_object->function()->code()->instruction_start(); |
| 2951 int offset = generator_object->continuation(); | 2957 int offset = generator_object->continuation(); |
| 2952 ASSERT(offset > 0); | 2958 ASSERT(offset > 0); |
| 2953 frame->set_pc(pc + offset); | 2959 frame->set_pc(pc + offset); |
| 2954 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting); | 2960 generator_object->set_continuation(JSGeneratorObject::kGeneratorExecuting); |
| 2955 | 2961 |
| (...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4962 LookupResult lookup(isolate); | 4968 LookupResult lookup(isolate); |
| 4963 object->LookupRealNamedProperty(*key, &lookup); | 4969 object->LookupRealNamedProperty(*key, &lookup); |
| 4964 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); | 4970 if (!lookup.IsFound()) return isolate->heap()->undefined_value(); |
| 4965 switch (lookup.type()) { | 4971 switch (lookup.type()) { |
| 4966 case NORMAL: | 4972 case NORMAL: |
| 4967 return lookup.holder()->GetNormalizedProperty(&lookup); | 4973 return lookup.holder()->GetNormalizedProperty(&lookup); |
| 4968 case FIELD: | 4974 case FIELD: |
| 4969 return lookup.holder()->FastPropertyAt( | 4975 return lookup.holder()->FastPropertyAt( |
| 4970 lookup.representation(), | 4976 lookup.representation(), |
| 4971 lookup.GetFieldIndex().field_index()); | 4977 lookup.GetFieldIndex().field_index()); |
| 4972 case CONSTANT_FUNCTION: | 4978 case CONSTANT: |
| 4973 return lookup.GetConstantFunction(); | 4979 return lookup.GetConstant(); |
| 4974 case CALLBACKS: | 4980 case CALLBACKS: |
| 4975 case HANDLER: | 4981 case HANDLER: |
| 4976 case INTERCEPTOR: | 4982 case INTERCEPTOR: |
| 4977 case TRANSITION: | 4983 case TRANSITION: |
| 4978 return isolate->heap()->undefined_value(); | 4984 return isolate->heap()->undefined_value(); |
| 4979 case NONEXISTENT: | 4985 case NONEXISTENT: |
| 4980 UNREACHABLE(); | 4986 UNREACHABLE(); |
| 4981 } | 4987 } |
| 4982 return isolate->heap()->undefined_value(); | 4988 return isolate->heap()->undefined_value(); |
| 4983 } | 4989 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5218 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { | 5224 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { |
| 5219 HandleScope scope(isolate); | 5225 HandleScope scope(isolate); |
| 5220 RUNTIME_ASSERT(args.length() == 2); | 5226 RUNTIME_ASSERT(args.length() == 2); |
| 5221 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 5227 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
| 5222 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 5228 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
| 5223 JSObject::TransitionElementsKind(array, map->elements_kind()); | 5229 JSObject::TransitionElementsKind(array, map->elements_kind()); |
| 5224 return *array; | 5230 return *array; |
| 5225 } | 5231 } |
| 5226 | 5232 |
| 5227 | 5233 |
| 5228 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsSmiToDouble) { | |
| 5229 SealHandleScope shs(isolate); | |
| 5230 RUNTIME_ASSERT(args.length() == 1); | |
| 5231 Handle<Object> object = args.at<Object>(0); | |
| 5232 if (object->IsJSObject()) { | |
| 5233 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | |
| 5234 ASSERT(!js_object->map()->is_observed()); | |
| 5235 ElementsKind new_kind = js_object->HasFastHoleyElements() | |
| 5236 ? FAST_HOLEY_DOUBLE_ELEMENTS | |
| 5237 : FAST_DOUBLE_ELEMENTS; | |
| 5238 return TransitionElements(object, new_kind, isolate); | |
| 5239 } else { | |
| 5240 return *object; | |
| 5241 } | |
| 5242 } | |
| 5243 | |
| 5244 | |
| 5245 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsDoubleToObject) { | |
| 5246 SealHandleScope shs(isolate); | |
| 5247 RUNTIME_ASSERT(args.length() == 1); | |
| 5248 Handle<Object> object = args.at<Object>(0); | |
| 5249 if (object->IsJSObject()) { | |
| 5250 Handle<JSObject> js_object(Handle<JSObject>::cast(object)); | |
| 5251 ASSERT(!js_object->map()->is_observed()); | |
| 5252 ElementsKind new_kind = js_object->HasFastHoleyElements() | |
| 5253 ? FAST_HOLEY_ELEMENTS | |
| 5254 : FAST_ELEMENTS; | |
| 5255 return TransitionElements(object, new_kind, isolate); | |
| 5256 } else { | |
| 5257 return *object; | |
| 5258 } | |
| 5259 } | |
| 5260 | |
| 5261 | |
| 5262 // Set the native flag on the function. | 5234 // Set the native flag on the function. |
| 5263 // This is used to decide if we should transform null and undefined | 5235 // This is used to decide if we should transform null and undefined |
| 5264 // into the global object when doing call and apply. | 5236 // into the global object when doing call and apply. |
| 5265 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 5237 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { |
| 5266 SealHandleScope shs(isolate); | 5238 SealHandleScope shs(isolate); |
| 5267 RUNTIME_ASSERT(args.length() == 1); | 5239 RUNTIME_ASSERT(args.length() == 1); |
| 5268 | 5240 |
| 5269 Handle<Object> object = args.at<Object>(0); | 5241 Handle<Object> object = args.at<Object>(0); |
| 5270 | 5242 |
| 5271 if (object->IsJSFunction()) { | 5243 if (object->IsJSFunction()) { |
| (...skipping 3181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8453 } | 8425 } |
| 8454 bool sync_with_compiler_thread = true; | 8426 bool sync_with_compiler_thread = true; |
| 8455 if (args.length() == 2) { | 8427 if (args.length() == 2) { |
| 8456 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8428 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
| 8457 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8429 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
| 8458 sync_with_compiler_thread = false; | 8430 sync_with_compiler_thread = false; |
| 8459 } | 8431 } |
| 8460 } | 8432 } |
| 8461 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8433 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8462 if (FLAG_parallel_recompilation && sync_with_compiler_thread) { | 8434 if (FLAG_parallel_recompilation && sync_with_compiler_thread) { |
| 8463 while (function->IsMarkedForParallelRecompilation() || | 8435 while (function->IsInRecompileQueue() || |
| 8464 function->IsInRecompileQueue() || | |
| 8465 function->IsMarkedForInstallingRecompiledCode()) { | 8436 function->IsMarkedForInstallingRecompiledCode()) { |
| 8466 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8437 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 8467 OS::Sleep(50); | 8438 OS::Sleep(50); |
| 8468 } | 8439 } |
| 8469 } | 8440 } |
| 8470 if (FLAG_always_opt) { | 8441 if (FLAG_always_opt) { |
| 8471 // We may have always opt, but that is more best-effort than a real | 8442 // We may have always opt, but that is more best-effort than a real |
| 8472 // promise, so we still say "no" if it is not optimized. | 8443 // promise, so we still say "no" if it is not optimized. |
| 8473 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8444 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
| 8474 : Smi::FromInt(2); // 2 == "no". | 8445 : Smi::FromInt(2); // 2 == "no". |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10547 MaybeObject* maybe_value = | 10518 MaybeObject* maybe_value = |
| 10548 JSObject::cast(result->holder())->FastPropertyAt( | 10519 JSObject::cast(result->holder())->FastPropertyAt( |
| 10549 result->representation(), | 10520 result->representation(), |
| 10550 result->GetFieldIndex().field_index()); | 10521 result->GetFieldIndex().field_index()); |
| 10551 if (!maybe_value->To(&value)) return maybe_value; | 10522 if (!maybe_value->To(&value)) return maybe_value; |
| 10552 if (value->IsTheHole()) { | 10523 if (value->IsTheHole()) { |
| 10553 return heap->undefined_value(); | 10524 return heap->undefined_value(); |
| 10554 } | 10525 } |
| 10555 return value; | 10526 return value; |
| 10556 } | 10527 } |
| 10557 case CONSTANT_FUNCTION: | 10528 case CONSTANT: |
| 10558 return result->GetConstantFunction(); | 10529 return result->GetConstant(); |
| 10559 case CALLBACKS: { | 10530 case CALLBACKS: { |
| 10560 Object* structure = result->GetCallbackObject(); | 10531 Object* structure = result->GetCallbackObject(); |
| 10561 if (structure->IsForeign() || structure->IsAccessorInfo()) { | 10532 if (structure->IsForeign() || structure->IsAccessorInfo()) { |
| 10562 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( | 10533 MaybeObject* maybe_value = result->holder()->GetPropertyWithCallback( |
| 10563 receiver, structure, name); | 10534 receiver, structure, name); |
| 10564 if (!maybe_value->ToObject(&value)) { | 10535 if (!maybe_value->ToObject(&value)) { |
| 10565 if (maybe_value->IsRetryAfterGC()) return maybe_value; | 10536 if (maybe_value->IsRetryAfterGC()) return maybe_value; |
| 10566 ASSERT(maybe_value->IsException()); | 10537 ASSERT(maybe_value->IsException()); |
| 10567 maybe_value = heap->isolate()->pending_exception(); | 10538 maybe_value = heap->isolate()->pending_exception(); |
| 10568 heap->isolate()->clear_pending_exception(); | 10539 heap->isolate()->clear_pending_exception(); |
| (...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13338 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 13309 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
| 13339 if (!Smi::IsValid(usage)) { | 13310 if (!Smi::IsValid(usage)) { |
| 13340 return *isolate->factory()->NewNumberFromInt(usage); | 13311 return *isolate->factory()->NewNumberFromInt(usage); |
| 13341 } | 13312 } |
| 13342 return Smi::FromInt(usage); | 13313 return Smi::FromInt(usage); |
| 13343 } | 13314 } |
| 13344 | 13315 |
| 13345 #endif // ENABLE_DEBUGGER_SUPPORT | 13316 #endif // ENABLE_DEBUGGER_SUPPORT |
| 13346 | 13317 |
| 13347 | 13318 |
| 13348 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | |
| 13349 SealHandleScope shs(isolate); | |
| 13350 v8::V8::ResumeProfiler(); | |
| 13351 return isolate->heap()->undefined_value(); | |
| 13352 } | |
| 13353 | |
| 13354 | |
| 13355 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerPause) { | |
| 13356 SealHandleScope shs(isolate); | |
| 13357 v8::V8::PauseProfiler(); | |
| 13358 return isolate->heap()->undefined_value(); | |
| 13359 } | |
| 13360 | |
| 13361 | |
| 13362 // Finds the script object from the script data. NOTE: This operation uses | 13319 // Finds the script object from the script data. NOTE: This operation uses |
| 13363 // heap traversal to find the function generated for the source position | 13320 // heap traversal to find the function generated for the source position |
| 13364 // for the requested break point. For lazily compiled functions several heap | 13321 // for the requested break point. For lazily compiled functions several heap |
| 13365 // traversals might be required rendering this operation as a rather slow | 13322 // traversals might be required rendering this operation as a rather slow |
| 13366 // operation. However for setting break points which is normally done through | 13323 // operation. However for setting break points which is normally done through |
| 13367 // some kind of user interaction the performance is not crucial. | 13324 // some kind of user interaction the performance is not crucial. |
| 13368 static Handle<Object> Runtime_GetScriptFromScriptName( | 13325 static Handle<Object> Runtime_GetScriptFromScriptName( |
| 13369 Handle<String> script_name) { | 13326 Handle<String> script_name) { |
| 13370 // Scan the heap for Script objects to find the script with the requested | 13327 // Scan the heap for Script objects to find the script with the requested |
| 13371 // script data. | 13328 // script data. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13422 Handle<Object> caller = args.at<Object>(1); | 13379 Handle<Object> caller = args.at<Object>(1); |
| 13423 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); | 13380 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); |
| 13424 | 13381 |
| 13425 // Optionally capture a more detailed stack trace for the message. | 13382 // Optionally capture a more detailed stack trace for the message. |
| 13426 isolate->CaptureAndSetDetailedStackTrace(error_object); | 13383 isolate->CaptureAndSetDetailedStackTrace(error_object); |
| 13427 // Capture a simple stack trace for the stack property. | 13384 // Capture a simple stack trace for the stack property. |
| 13428 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); | 13385 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); |
| 13429 } | 13386 } |
| 13430 | 13387 |
| 13431 | 13388 |
| 13432 // Mark a function to recognize when called after GC to format the stack trace. | 13389 // Retrieve the stack trace. This is the raw stack trace that yet has to |
| 13433 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { | 13390 // be formatted. Since we only need this once, clear it afterwards. |
| 13434 HandleScope scope(isolate); | 13391 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { |
| 13435 ASSERT_EQ(args.length(), 1); | |
| 13436 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | |
| 13437 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | |
| 13438 JSObject::SetHiddenProperty(fun, key, key); | |
| 13439 return *fun; | |
| 13440 } | |
| 13441 | |
| 13442 | |
| 13443 // Retrieve the stack trace. This could be the raw stack trace collected | |
| 13444 // on stack overflow or the already formatted stack trace string. | |
| 13445 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { | |
| 13446 HandleScope scope(isolate); | 13392 HandleScope scope(isolate); |
| 13447 ASSERT_EQ(args.length(), 1); | 13393 ASSERT_EQ(args.length(), 1); |
| 13448 CONVERT_ARG_CHECKED(JSObject, error_object, 0); | 13394 CONVERT_ARG_CHECKED(JSObject, error_object, 0); |
| 13449 String* key = isolate->heap()->hidden_stack_trace_string(); | 13395 String* key = isolate->heap()->hidden_stack_trace_string(); |
| 13450 Object* result = error_object->GetHiddenProperty(key); | 13396 Object* result = error_object->GetHiddenProperty(key); |
| 13451 if (result->IsTheHole()) result = isolate->heap()->undefined_value(); | 13397 if (result->IsTheHole()) return isolate->heap()->undefined_value(); |
| 13452 RUNTIME_ASSERT(result->IsJSArray() || | 13398 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
| 13453 result->IsString() || | 13399 error_object->DeleteHiddenProperty(key); |
| 13454 result->IsUndefined()); | |
| 13455 return result; | 13400 return result; |
| 13456 } | 13401 } |
| 13457 | 13402 |
| 13458 | 13403 |
| 13459 // Set or clear the stack trace attached to an stack overflow error object. | |
| 13460 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) { | |
| 13461 HandleScope scope(isolate); | |
| 13462 ASSERT_EQ(args.length(), 2); | |
| 13463 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | |
| 13464 CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1); | |
| 13465 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | |
| 13466 if (value->IsUndefined()) { | |
| 13467 error_object->DeleteHiddenProperty(*key); | |
| 13468 } else { | |
| 13469 RUNTIME_ASSERT(value->IsString()); | |
| 13470 JSObject::SetHiddenProperty(error_object, key, value); | |
| 13471 } | |
| 13472 return *error_object; | |
| 13473 } | |
| 13474 | |
| 13475 | |
| 13476 // Returns V8 version as a string. | 13404 // Returns V8 version as a string. |
| 13477 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 13405 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { |
| 13478 SealHandleScope shs(isolate); | 13406 SealHandleScope shs(isolate); |
| 13479 ASSERT_EQ(args.length(), 0); | 13407 ASSERT_EQ(args.length(), 0); |
| 13480 | 13408 |
| 13481 const char* version_string = v8::V8::GetVersion(); | 13409 const char* version_string = v8::V8::GetVersion(); |
| 13482 | 13410 |
| 13483 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), | 13411 return isolate->heap()->AllocateStringFromOneByte(CStrVector(version_string), |
| 13484 NOT_TENURED); | 13412 NOT_TENURED); |
| 13485 } | 13413 } |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13979 // Handle last resort GC and make sure to allow future allocations | 13907 // Handle last resort GC and make sure to allow future allocations |
| 13980 // to grow the heap without causing GCs (if possible). | 13908 // to grow the heap without causing GCs (if possible). |
| 13981 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13909 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13982 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13910 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13983 "Runtime::PerformGC"); | 13911 "Runtime::PerformGC"); |
| 13984 } | 13912 } |
| 13985 } | 13913 } |
| 13986 | 13914 |
| 13987 | 13915 |
| 13988 } } // namespace v8::internal | 13916 } } // namespace v8::internal |
| OLD | NEW |