| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 Handle<Object> value(constant_properties->get(index+1), isolate); | 283 Handle<Object> value(constant_properties->get(index+1), isolate); |
| 284 if (value->IsFixedArray()) { | 284 if (value->IsFixedArray()) { |
| 285 // The value contains the constant_properties of a | 285 // The value contains the constant_properties of a |
| 286 // simple object or array literal. | 286 // simple object or array literal. |
| 287 Handle<FixedArray> array = Handle<FixedArray>::cast(value); | 287 Handle<FixedArray> array = Handle<FixedArray>::cast(value); |
| 288 value = CreateLiteralBoilerplate(isolate, literals, array); | 288 value = CreateLiteralBoilerplate(isolate, literals, array); |
| 289 if (value.is_null()) return value; | 289 if (value.is_null()) return value; |
| 290 } | 290 } |
| 291 Handle<Object> result; | 291 Handle<Object> result; |
| 292 uint32_t element_index = 0; | 292 uint32_t element_index = 0; |
| 293 JSReceiver::StoreMode mode = value->IsJSObject() | 293 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; |
| 294 ? JSReceiver::FORCE_FIELD | |
| 295 : JSReceiver::ALLOW_AS_CONSTANT; | |
| 296 if (key->IsInternalizedString()) { | 294 if (key->IsInternalizedString()) { |
| 297 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { | 295 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { |
| 298 // Array index as string (uint32). | 296 // Array index as string (uint32). |
| 299 result = JSObject::SetOwnElement( | 297 result = JSObject::SetOwnElement( |
| 300 boilerplate, element_index, value, kNonStrictMode); | 298 boilerplate, element_index, value, kNonStrictMode); |
| 301 } else { | 299 } else { |
| 302 Handle<String> name(String::cast(*key)); | 300 Handle<String> name(String::cast(*key)); |
| 303 ASSERT(!name->AsArrayIndex(&element_index)); | 301 ASSERT(!name->AsArrayIndex(&element_index)); |
| 304 result = JSObject::SetLocalPropertyIgnoreAttributes( | 302 result = JSObject::SetLocalPropertyIgnoreAttributes( |
| 305 boilerplate, name, value, NONE, | 303 boilerplate, name, value, NONE, |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 static bool CheckAccessException(Object* callback, | 1655 static bool CheckAccessException(Object* callback, |
| 1658 v8::AccessType access_type) { | 1656 v8::AccessType access_type) { |
| 1659 if (callback->IsAccessorInfo()) { | 1657 if (callback->IsAccessorInfo()) { |
| 1660 AccessorInfo* info = AccessorInfo::cast(callback); | 1658 AccessorInfo* info = AccessorInfo::cast(callback); |
| 1661 return | 1659 return |
| 1662 (access_type == v8::ACCESS_HAS && | 1660 (access_type == v8::ACCESS_HAS && |
| 1663 (info->all_can_read() || info->all_can_write())) || | 1661 (info->all_can_read() || info->all_can_write())) || |
| 1664 (access_type == v8::ACCESS_GET && info->all_can_read()) || | 1662 (access_type == v8::ACCESS_GET && info->all_can_read()) || |
| 1665 (access_type == v8::ACCESS_SET && info->all_can_write()); | 1663 (access_type == v8::ACCESS_SET && info->all_can_write()); |
| 1666 } | 1664 } |
| 1665 if (callback->IsAccessorPair()) { |
| 1666 AccessorPair* info = AccessorPair::cast(callback); |
| 1667 return |
| 1668 (access_type == v8::ACCESS_HAS && |
| 1669 (info->all_can_read() || info->all_can_write())) || |
| 1670 (access_type == v8::ACCESS_GET && info->all_can_read()) || |
| 1671 (access_type == v8::ACCESS_SET && info->all_can_write()); |
| 1672 } |
| 1667 return false; | 1673 return false; |
| 1668 } | 1674 } |
| 1669 | 1675 |
| 1670 | 1676 |
| 1671 template<class Key> | 1677 template<class Key> |
| 1672 static bool CheckGenericAccess( | 1678 static bool CheckGenericAccess( |
| 1673 JSObject* receiver, | 1679 JSObject* receiver, |
| 1674 JSObject* holder, | 1680 JSObject* holder, |
| 1675 Key key, | 1681 Key key, |
| 1676 v8::AccessType access_type, | 1682 v8::AccessType access_type, |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 MaybeObject* maybe_new_map = old_map->Copy(); | 1944 MaybeObject* maybe_new_map = old_map->Copy(); |
| 1939 if (!maybe_new_map->To(&new_map)) return maybe_new_map; | 1945 if (!maybe_new_map->To(&new_map)) return maybe_new_map; |
| 1940 | 1946 |
| 1941 new_map->set_is_access_check_needed(true); | 1947 new_map->set_is_access_check_needed(true); |
| 1942 object->set_map(new_map); | 1948 object->set_map(new_map); |
| 1943 } | 1949 } |
| 1944 return isolate->heap()->undefined_value(); | 1950 return isolate->heap()->undefined_value(); |
| 1945 } | 1951 } |
| 1946 | 1952 |
| 1947 | 1953 |
| 1954 // Transform getter or setter into something DefineAccessor can handle. |
| 1955 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, |
| 1956 Handle<Object> component) { |
| 1957 if (component->IsUndefined()) return isolate->factory()->null_value(); |
| 1958 Handle<FunctionTemplateInfo> info = |
| 1959 Handle<FunctionTemplateInfo>::cast(component); |
| 1960 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
| 1961 } |
| 1962 |
| 1963 |
| 1964 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { |
| 1965 HandleScope scope(isolate); |
| 1966 ASSERT(args.length() == 6); |
| 1967 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
| 1968 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
| 1969 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
| 1970 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
| 1971 CONVERT_SMI_ARG_CHECKED(attribute, 4); |
| 1972 CONVERT_SMI_ARG_CHECKED(access_control, 5); |
| 1973 JSObject::DefineAccessor(object, |
| 1974 name, |
| 1975 InstantiateAccessorComponent(isolate, getter), |
| 1976 InstantiateAccessorComponent(isolate, setter), |
| 1977 static_cast<PropertyAttributes>(attribute), |
| 1978 static_cast<v8::AccessControl>(access_control)); |
| 1979 return isolate->heap()->undefined_value(); |
| 1980 } |
| 1981 |
| 1982 |
| 1948 static Failure* ThrowRedeclarationError(Isolate* isolate, | 1983 static Failure* ThrowRedeclarationError(Isolate* isolate, |
| 1949 const char* type, | 1984 const char* type, |
| 1950 Handle<String> name) { | 1985 Handle<String> name) { |
| 1951 HandleScope scope(isolate); | 1986 HandleScope scope(isolate); |
| 1952 Handle<Object> type_handle = | 1987 Handle<Object> type_handle = |
| 1953 isolate->factory()->NewStringFromAscii(CStrVector(type)); | 1988 isolate->factory()->NewStringFromAscii(CStrVector(type)); |
| 1954 Handle<Object> args[2] = { type_handle, name }; | 1989 Handle<Object> args[2] = { type_handle, name }; |
| 1955 Handle<Object> error = | 1990 Handle<Object> error = |
| 1956 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); | 1991 isolate->factory()->NewTypeError("redeclaration", HandleVector(args, 2)); |
| 1957 return isolate->Throw(*error); | 1992 return isolate->Throw(*error); |
| (...skipping 5951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7909 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 7944 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 7910 for (int i = 0; i < length; i++) { | 7945 for (int i = 0; i < length; i++) { |
| 7911 array->set(i, *--parameters, mode); | 7946 array->set(i, *--parameters, mode); |
| 7912 } | 7947 } |
| 7913 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); | 7948 JSObject::cast(result)->set_elements(FixedArray::cast(obj)); |
| 7914 } | 7949 } |
| 7915 return result; | 7950 return result; |
| 7916 } | 7951 } |
| 7917 | 7952 |
| 7918 | 7953 |
| 7954 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosureFromStubFailure) { |
| 7955 HandleScope scope(isolate); |
| 7956 ASSERT(args.length() == 1); |
| 7957 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
| 7958 Handle<Context> context(isolate->context()); |
| 7959 PretenureFlag pretenure_flag = NOT_TENURED; |
| 7960 Handle<JSFunction> result = |
| 7961 isolate->factory()->NewFunctionFromSharedFunctionInfo(shared, |
| 7962 context, |
| 7963 pretenure_flag); |
| 7964 return *result; |
| 7965 } |
| 7966 |
| 7967 |
| 7919 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { | 7968 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewClosure) { |
| 7920 HandleScope scope(isolate); | 7969 HandleScope scope(isolate); |
| 7921 ASSERT(args.length() == 3); | 7970 ASSERT(args.length() == 3); |
| 7922 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 7971 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
| 7923 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); | 7972 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); |
| 7924 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); | 7973 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); |
| 7925 | 7974 |
| 7926 // The caller ensures that we pretenure closures that are assigned | 7975 // The caller ensures that we pretenure closures that are assigned |
| 7927 // directly to properties. | 7976 // directly to properties. |
| 7928 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 7977 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8258 if (FLAG_trace_opt) { | 8307 if (FLAG_trace_opt) { |
| 8259 PrintF("[failed to optimize "); | 8308 PrintF("[failed to optimize "); |
| 8260 function->PrintName(); | 8309 function->PrintName(); |
| 8261 PrintF(": optimized compilation failed]\n"); | 8310 PrintF(": optimized compilation failed]\n"); |
| 8262 } | 8311 } |
| 8263 function->ReplaceCode(function->shared()->code()); | 8312 function->ReplaceCode(function->shared()->code()); |
| 8264 return function->code(); | 8313 return function->code(); |
| 8265 } | 8314 } |
| 8266 | 8315 |
| 8267 | 8316 |
| 8268 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParallelRecompile) { | 8317 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConcurrentRecompile) { |
| 8269 HandleScope handle_scope(isolate); | 8318 HandleScope handle_scope(isolate); |
| 8270 ASSERT(args.length() == 1); | 8319 ASSERT(args.length() == 1); |
| 8271 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8320 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8272 if (!AllowOptimization(isolate, function)) { | 8321 if (!AllowOptimization(isolate, function)) { |
| 8273 function->ReplaceCode(function->shared()->code()); | 8322 function->ReplaceCode(function->shared()->code()); |
| 8274 return isolate->heap()->undefined_value(); | 8323 return isolate->heap()->undefined_value(); |
| 8275 } | 8324 } |
| 8276 function->shared()->code()->set_profiler_ticks(0); | 8325 function->shared()->code()->set_profiler_ticks(0); |
| 8277 ASSERT(FLAG_parallel_recompilation); | 8326 ASSERT(FLAG_concurrent_recompilation); |
| 8278 Compiler::RecompileParallel(function); | 8327 Compiler::RecompileConcurrent(function); |
| 8279 return isolate->heap()->undefined_value(); | 8328 return isolate->heap()->undefined_value(); |
| 8280 } | 8329 } |
| 8281 | 8330 |
| 8282 | 8331 |
| 8283 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { | 8332 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { |
| 8284 HandleScope handle_scope(isolate); | 8333 HandleScope handle_scope(isolate); |
| 8285 ASSERT(args.length() == 1); | 8334 ASSERT(args.length() == 1); |
| 8286 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8335 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8287 ASSERT(V8::UseCrankshaft() && FLAG_parallel_recompilation); | 8336 ASSERT(V8::UseCrankshaft() && FLAG_concurrent_recompilation); |
| 8288 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8337 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 8289 return function->code(); | 8338 return function->code(); |
| 8290 } | 8339 } |
| 8291 | 8340 |
| 8292 | 8341 |
| 8293 class ActivationsFinder : public ThreadVisitor { | 8342 class ActivationsFinder : public ThreadVisitor { |
| 8294 public: | 8343 public: |
| 8295 explicit ActivationsFinder(JSFunction* function) | 8344 Code* code_; |
| 8296 : function_(function), has_activations_(false) {} | 8345 bool has_code_activations_; |
| 8346 |
| 8347 explicit ActivationsFinder(Code* code) |
| 8348 : code_(code), |
| 8349 has_code_activations_(false) { } |
| 8297 | 8350 |
| 8298 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { | 8351 void VisitThread(Isolate* isolate, ThreadLocalTop* top) { |
| 8299 if (has_activations_) return; | 8352 JavaScriptFrameIterator it(isolate, top); |
| 8353 VisitFrames(&it); |
| 8354 } |
| 8300 | 8355 |
| 8301 for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) { | 8356 void VisitFrames(JavaScriptFrameIterator* it) { |
| 8302 JavaScriptFrame* frame = it.frame(); | 8357 for (; !it->done(); it->Advance()) { |
| 8303 if (frame->is_optimized() && frame->function() == function_) { | 8358 JavaScriptFrame* frame = it->frame(); |
| 8304 has_activations_ = true; | 8359 if (code_->contains(frame->pc())) has_code_activations_ = true; |
| 8305 return; | |
| 8306 } | |
| 8307 } | 8360 } |
| 8308 } | 8361 } |
| 8309 | |
| 8310 bool has_activations() { return has_activations_; } | |
| 8311 | |
| 8312 private: | |
| 8313 JSFunction* function_; | |
| 8314 bool has_activations_; | |
| 8315 }; | 8362 }; |
| 8316 | 8363 |
| 8317 | 8364 |
| 8318 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyStubFailure) { | 8365 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyStubFailure) { |
| 8319 HandleScope scope(isolate); | 8366 HandleScope scope(isolate); |
| 8320 ASSERT(args.length() == 0); | 8367 ASSERT(args.length() == 0); |
| 8321 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8368 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8322 ASSERT(AllowHeapAllocation::IsAllowed()); | 8369 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8323 delete deoptimizer; | 8370 delete deoptimizer; |
| 8324 return isolate->heap()->undefined_value(); | 8371 return isolate->heap()->undefined_value(); |
| 8325 } | 8372 } |
| 8326 | 8373 |
| 8327 | 8374 |
| 8328 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { | 8375 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { |
| 8329 HandleScope scope(isolate); | 8376 HandleScope scope(isolate); |
| 8330 ASSERT(args.length() == 1); | 8377 ASSERT(args.length() == 1); |
| 8331 RUNTIME_ASSERT(args[0]->IsSmi()); | 8378 RUNTIME_ASSERT(args[0]->IsSmi()); |
| 8332 Deoptimizer::BailoutType type = | 8379 Deoptimizer::BailoutType type = |
| 8333 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); | 8380 static_cast<Deoptimizer::BailoutType>(args.smi_at(0)); |
| 8334 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8381 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
| 8335 ASSERT(AllowHeapAllocation::IsAllowed()); | 8382 ASSERT(AllowHeapAllocation::IsAllowed()); |
| 8336 | 8383 |
| 8337 ASSERT(deoptimizer->compiled_code_kind() == Code::OPTIMIZED_FUNCTION); | 8384 Handle<JSFunction> function = deoptimizer->function(); |
| 8385 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
| 8386 |
| 8387 ASSERT(optimized_code->kind() == Code::OPTIMIZED_FUNCTION); |
| 8388 ASSERT(type == deoptimizer->bailout_type()); |
| 8338 | 8389 |
| 8339 // Make sure to materialize objects before causing any allocation. | 8390 // Make sure to materialize objects before causing any allocation. |
| 8340 JavaScriptFrameIterator it(isolate); | 8391 JavaScriptFrameIterator it(isolate); |
| 8341 deoptimizer->MaterializeHeapObjects(&it); | 8392 deoptimizer->MaterializeHeapObjects(&it); |
| 8342 delete deoptimizer; | 8393 delete deoptimizer; |
| 8343 | 8394 |
| 8344 JavaScriptFrame* frame = it.frame(); | 8395 JavaScriptFrame* frame = it.frame(); |
| 8345 RUNTIME_ASSERT(frame->function()->IsJSFunction()); | 8396 RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
| 8346 Handle<JSFunction> function(frame->function(), isolate); | |
| 8347 Handle<Code> optimized_code(function->code()); | |
| 8348 RUNTIME_ASSERT((type != Deoptimizer::EAGER && | |
| 8349 type != Deoptimizer::SOFT) || function->IsOptimized()); | |
| 8350 | 8397 |
| 8351 // Avoid doing too much work when running with --always-opt and keep | 8398 // Avoid doing too much work when running with --always-opt and keep |
| 8352 // the optimized code around. | 8399 // the optimized code around. |
| 8353 if (FLAG_always_opt || type == Deoptimizer::LAZY) { | 8400 if (FLAG_always_opt || type == Deoptimizer::LAZY) { |
| 8354 return isolate->heap()->undefined_value(); | 8401 return isolate->heap()->undefined_value(); |
| 8355 } | 8402 } |
| 8356 | 8403 |
| 8357 // Find other optimized activations of the function or functions that | 8404 // Search for other activations of the same function and code. |
| 8358 // share the same optimized code. | 8405 ActivationsFinder activations_finder(*optimized_code); |
| 8359 bool has_other_activations = false; | 8406 activations_finder.VisitFrames(&it); |
| 8360 while (!it.done()) { | 8407 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); |
| 8361 JavaScriptFrame* frame = it.frame(); | 8408 |
| 8362 JSFunction* other_function = frame->function(); | 8409 if (!activations_finder.has_code_activations_) { |
| 8363 if (frame->is_optimized() && other_function->code() == function->code()) { | 8410 if (function->code() == *optimized_code) { |
| 8364 has_other_activations = true; | 8411 if (FLAG_trace_deopt) { |
| 8365 break; | 8412 PrintF("[removing optimized code for: "); |
| 8413 function->PrintName(); |
| 8414 PrintF("]\n"); |
| 8415 } |
| 8416 function->ReplaceCode(function->shared()->code()); |
| 8366 } | 8417 } |
| 8367 it.Advance(); | |
| 8368 } | |
| 8369 | |
| 8370 if (!has_other_activations) { | |
| 8371 ActivationsFinder activations_finder(*function); | |
| 8372 isolate->thread_manager()->IterateArchivedThreads(&activations_finder); | |
| 8373 has_other_activations = activations_finder.has_activations(); | |
| 8374 } | |
| 8375 | |
| 8376 if (!has_other_activations) { | |
| 8377 if (FLAG_trace_deopt) { | |
| 8378 PrintF("[removing optimized code for: "); | |
| 8379 function->PrintName(); | |
| 8380 PrintF("]\n"); | |
| 8381 } | |
| 8382 function->ReplaceCode(function->shared()->code()); | |
| 8383 } else { | 8418 } else { |
| 8419 // TODO(titzer): we should probably do DeoptimizeCodeList(code) |
| 8420 // unconditionally if the code is not already marked for deoptimization. |
| 8421 // If there is an index by shared function info, all the better. |
| 8384 Deoptimizer::DeoptimizeFunction(*function); | 8422 Deoptimizer::DeoptimizeFunction(*function); |
| 8385 } | 8423 } |
| 8386 // Evict optimized code for this function from the cache so that it doesn't | 8424 // Evict optimized code for this function from the cache so that it doesn't |
| 8387 // get used for new closures. | 8425 // get used for new closures. |
| 8388 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, | 8426 function->shared()->EvictFromOptimizedCodeMap(*optimized_code, |
| 8389 "notify deoptimized"); | 8427 "notify deoptimized"); |
| 8390 | 8428 |
| 8391 return isolate->heap()->undefined_value(); | 8429 return isolate->heap()->undefined_value(); |
| 8392 } | 8430 } |
| 8393 | 8431 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8428 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { | 8466 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { |
| 8429 SealHandleScope shs(isolate); | 8467 SealHandleScope shs(isolate); |
| 8430 #if defined(USE_SIMULATOR) | 8468 #if defined(USE_SIMULATOR) |
| 8431 return isolate->heap()->true_value(); | 8469 return isolate->heap()->true_value(); |
| 8432 #else | 8470 #else |
| 8433 return isolate->heap()->false_value(); | 8471 return isolate->heap()->false_value(); |
| 8434 #endif | 8472 #endif |
| 8435 } | 8473 } |
| 8436 | 8474 |
| 8437 | 8475 |
| 8438 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsParallelRecompilationSupported) { | 8476 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) { |
| 8439 HandleScope scope(isolate); | 8477 HandleScope scope(isolate); |
| 8440 return FLAG_parallel_recompilation | 8478 return FLAG_concurrent_recompilation |
| 8441 ? isolate->heap()->true_value() : isolate->heap()->false_value(); | 8479 ? isolate->heap()->true_value() : isolate->heap()->false_value(); |
| 8442 } | 8480 } |
| 8443 | 8481 |
| 8444 | 8482 |
| 8445 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { | 8483 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { |
| 8446 HandleScope scope(isolate); | 8484 HandleScope scope(isolate); |
| 8447 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8485 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
| 8448 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8486 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8449 | 8487 |
| 8450 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); | 8488 if (!function->IsOptimizable()) return isolate->heap()->undefined_value(); |
| 8451 function->MarkForLazyRecompilation(); | 8489 function->MarkForLazyRecompilation(); |
| 8452 | 8490 |
| 8453 Code* unoptimized = function->shared()->code(); | 8491 Code* unoptimized = function->shared()->code(); |
| 8454 if (args.length() == 2 && | 8492 if (args.length() == 2 && |
| 8455 unoptimized->kind() == Code::FUNCTION) { | 8493 unoptimized->kind() == Code::FUNCTION) { |
| 8456 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 8494 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
| 8457 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { | 8495 if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("osr"))) { |
| 8458 for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) { | 8496 for (int i = 0; i <= Code::kMaxLoopNestingMarker; i++) { |
| 8459 unoptimized->set_allow_osr_at_loop_nesting_level(i); | 8497 unoptimized->set_allow_osr_at_loop_nesting_level(i); |
| 8460 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); | 8498 isolate->runtime_profiler()->AttemptOnStackReplacement(*function); |
| 8461 } | 8499 } |
| 8462 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("parallel"))) { | 8500 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent"))) { |
| 8463 function->MarkForParallelRecompilation(); | 8501 function->MarkForConcurrentRecompilation(); |
| 8464 } | 8502 } |
| 8465 } | 8503 } |
| 8466 | 8504 |
| 8467 return isolate->heap()->undefined_value(); | 8505 return isolate->heap()->undefined_value(); |
| 8468 } | 8506 } |
| 8469 | 8507 |
| 8470 | 8508 |
| 8471 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { | 8509 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { |
| 8472 HandleScope scope(isolate); | 8510 HandleScope scope(isolate); |
| 8473 ASSERT(args.length() == 1); | 8511 ASSERT(args.length() == 1); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8485 return Smi::FromInt(4); // 4 == "never". | 8523 return Smi::FromInt(4); // 4 == "never". |
| 8486 } | 8524 } |
| 8487 bool sync_with_compiler_thread = true; | 8525 bool sync_with_compiler_thread = true; |
| 8488 if (args.length() == 2) { | 8526 if (args.length() == 2) { |
| 8489 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8527 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
| 8490 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8528 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
| 8491 sync_with_compiler_thread = false; | 8529 sync_with_compiler_thread = false; |
| 8492 } | 8530 } |
| 8493 } | 8531 } |
| 8494 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8532 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8495 if (FLAG_parallel_recompilation && sync_with_compiler_thread) { | 8533 if (FLAG_concurrent_recompilation && sync_with_compiler_thread) { |
| 8496 while (function->IsInRecompileQueue() || | 8534 while (function->IsInRecompileQueue() || |
| 8497 function->IsMarkedForInstallingRecompiledCode()) { | 8535 function->IsMarkedForInstallingRecompiledCode()) { |
| 8498 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 8536 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
| 8499 OS::Sleep(50); | 8537 OS::Sleep(50); |
| 8500 } | 8538 } |
| 8501 } | 8539 } |
| 8502 if (FLAG_always_opt) { | 8540 if (FLAG_always_opt) { |
| 8503 // We may have always opt, but that is more best-effort than a real | 8541 // We may have always opt, but that is more best-effort than a real |
| 8504 // promise, so we still say "no" if it is not optimized. | 8542 // promise, so we still say "no" if it is not optimized. |
| 8505 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8543 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
| (...skipping 4472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12978 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 13016 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
| 12979 script->set_source(*source); | 13017 script->set_source(*source); |
| 12980 | 13018 |
| 12981 return isolate->heap()->undefined_value(); | 13019 return isolate->heap()->undefined_value(); |
| 12982 } | 13020 } |
| 12983 | 13021 |
| 12984 | 13022 |
| 12985 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { | 13023 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { |
| 12986 SealHandleScope shs(isolate); | 13024 SealHandleScope shs(isolate); |
| 12987 ASSERT(args.length() == 0); | 13025 ASSERT(args.length() == 0); |
| 12988 CPU::DebugBreak(); | 13026 OS::DebugBreak(); |
| 12989 return isolate->heap()->undefined_value(); | 13027 return isolate->heap()->undefined_value(); |
| 12990 } | 13028 } |
| 12991 | 13029 |
| 12992 | 13030 |
| 12993 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { | 13031 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { |
| 12994 HandleScope scope(isolate); | 13032 HandleScope scope(isolate); |
| 12995 #ifdef DEBUG | 13033 #ifdef DEBUG |
| 12996 ASSERT(args.length() == 1); | 13034 ASSERT(args.length() == 1); |
| 12997 // Get the function and make sure it is compiled. | 13035 // Get the function and make sure it is compiled. |
| 12998 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13036 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14146 | 14184 |
| 14147 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { | 14185 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { |
| 14148 HandleScope scope(isolate); | 14186 HandleScope scope(isolate); |
| 14149 ASSERT(args.length() == 1); | 14187 ASSERT(args.length() == 1); |
| 14150 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14188 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
| 14151 FlattenString(str); | 14189 FlattenString(str); |
| 14152 return isolate->heap()->undefined_value(); | 14190 return isolate->heap()->undefined_value(); |
| 14153 } | 14191 } |
| 14154 | 14192 |
| 14155 | 14193 |
| 14194 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) { |
| 14195 HandleScope scope(isolate); |
| 14196 ASSERT(args.length() == 0); |
| 14197 isolate->heap()->NotifyContextDisposed(); |
| 14198 return isolate->heap()->undefined_value(); |
| 14199 } |
| 14200 |
| 14201 |
| 14156 RUNTIME_FUNCTION(MaybeObject*, Runtime_MigrateInstance) { | 14202 RUNTIME_FUNCTION(MaybeObject*, Runtime_MigrateInstance) { |
| 14157 HandleScope scope(isolate); | 14203 HandleScope scope(isolate); |
| 14158 ASSERT(args.length() == 1); | 14204 ASSERT(args.length() == 1); |
| 14159 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 14205 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 14160 if (!object->IsJSObject()) return Smi::FromInt(0); | 14206 if (!object->IsJSObject()) return Smi::FromInt(0); |
| 14161 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 14207 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
| 14162 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); | 14208 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); |
| 14163 JSObject::MigrateInstance(js_object); | 14209 JSObject::MigrateInstance(js_object); |
| 14164 return *object; | 14210 return *object; |
| 14165 } | 14211 } |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14641 // Handle last resort GC and make sure to allow future allocations | 14687 // Handle last resort GC and make sure to allow future allocations |
| 14642 // to grow the heap without causing GCs (if possible). | 14688 // to grow the heap without causing GCs (if possible). |
| 14643 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14689 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 14644 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14690 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 14645 "Runtime::PerformGC"); | 14691 "Runtime::PerformGC"); |
| 14646 } | 14692 } |
| 14647 } | 14693 } |
| 14648 | 14694 |
| 14649 | 14695 |
| 14650 } } // namespace v8::internal | 14696 } } // namespace v8::internal |
| OLD | NEW |