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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 if (table->IsKey(*key)) { | 1814 if (table->IsKey(*key)) { |
1815 values->set(number_of_non_hole_elements++, *key); | 1815 values->set(number_of_non_hole_elements++, *key); |
1816 } | 1816 } |
1817 } | 1817 } |
1818 ASSERT_EQ(table->NumberOfElements(), number_of_non_hole_elements); | 1818 ASSERT_EQ(table->NumberOfElements(), number_of_non_hole_elements); |
1819 } | 1819 } |
1820 return *isolate->factory()->NewJSArrayWithElements(values); | 1820 return *isolate->factory()->NewJSArrayWithElements(values); |
1821 } | 1821 } |
1822 | 1822 |
1823 | 1823 |
1824 RUNTIME_FUNCTION(Runtime_ClassOf) { | |
1825 SealHandleScope shs(isolate); | |
1826 ASSERT(args.length() == 1); | |
1827 CONVERT_ARG_CHECKED(Object, obj, 0); | |
1828 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | |
1829 return JSObject::cast(obj)->class_name(); | |
1830 } | |
1831 | |
1832 | |
1833 RUNTIME_FUNCTION(Runtime_GetPrototype) { | 1824 RUNTIME_FUNCTION(Runtime_GetPrototype) { |
1834 HandleScope scope(isolate); | 1825 HandleScope scope(isolate); |
1835 ASSERT(args.length() == 1); | 1826 ASSERT(args.length() == 1); |
1836 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 1827 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
1837 // We don't expect access checks to be needed on JSProxy objects. | 1828 // We don't expect access checks to be needed on JSProxy objects. |
1838 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1829 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
1839 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); | 1830 PrototypeIterator iter(isolate, obj, PrototypeIterator::START_AT_RECEIVER); |
1840 do { | 1831 do { |
1841 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && | 1832 if (PrototypeIterator::GetCurrent(iter)->IsAccessCheckNeeded() && |
1842 !isolate->MayNamedAccess( | 1833 !isolate->MayNamedAccess( |
(...skipping 4228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6071 case JS_FUNCTION_PROXY_TYPE: | 6062 case JS_FUNCTION_PROXY_TYPE: |
6072 return isolate->heap()->function_string(); | 6063 return isolate->heap()->function_string(); |
6073 default: | 6064 default: |
6074 // For any kind of object not handled above, the spec rule for | 6065 // For any kind of object not handled above, the spec rule for |
6075 // host objects gives that it is okay to return "object" | 6066 // host objects gives that it is okay to return "object" |
6076 return isolate->heap()->object_string(); | 6067 return isolate->heap()->object_string(); |
6077 } | 6068 } |
6078 } | 6069 } |
6079 | 6070 |
6080 | 6071 |
| 6072 RUNTIME_FUNCTION(Runtime_Booleanize) { |
| 6073 SealHandleScope shs(isolate); |
| 6074 ASSERT(args.length() == 2); |
| 6075 CONVERT_ARG_CHECKED(Object, value_raw, 0); |
| 6076 CONVERT_SMI_ARG_CHECKED(token_raw, 1); |
| 6077 intptr_t value = reinterpret_cast<intptr_t>(value_raw); |
| 6078 Token::Value token = static_cast<Token::Value>(token_raw); |
| 6079 switch (token) { |
| 6080 case Token::EQ: |
| 6081 case Token::EQ_STRICT: |
| 6082 return isolate->heap()->ToBoolean(value == 0); |
| 6083 case Token::NE: |
| 6084 case Token::NE_STRICT: |
| 6085 return isolate->heap()->ToBoolean(value != 0); |
| 6086 case Token::LT: |
| 6087 return isolate->heap()->ToBoolean(value < 0); |
| 6088 case Token::GT: |
| 6089 return isolate->heap()->ToBoolean(value > 0); |
| 6090 case Token::LTE: |
| 6091 return isolate->heap()->ToBoolean(value <= 0); |
| 6092 case Token::GTE: |
| 6093 return isolate->heap()->ToBoolean(value >= 0); |
| 6094 default: |
| 6095 // This should only happen during natives fuzzing. |
| 6096 return isolate->heap()->undefined_value(); |
| 6097 } |
| 6098 } |
| 6099 |
| 6100 |
6081 static bool AreDigits(const uint8_t*s, int from, int to) { | 6101 static bool AreDigits(const uint8_t*s, int from, int to) { |
6082 for (int i = from; i < to; i++) { | 6102 for (int i = from; i < to; i++) { |
6083 if (s[i] < '0' || s[i] > '9') return false; | 6103 if (s[i] < '0' || s[i] > '9') return false; |
6084 } | 6104 } |
6085 | 6105 |
6086 return true; | 6106 return true; |
6087 } | 6107 } |
6088 | 6108 |
6089 | 6109 |
6090 static int ParseDecimalInteger(const uint8_t*s, int from, int to) { | 6110 static int ParseDecimalInteger(const uint8_t*s, int from, int to) { |
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7863 is_value_nan = true; | 7883 is_value_nan = true; |
7864 } else { | 7884 } else { |
7865 value = isolate->factory()->NewNumber(DoubleToInteger(time)); | 7885 value = isolate->factory()->NewNumber(DoubleToInteger(time)); |
7866 } | 7886 } |
7867 } | 7887 } |
7868 date->SetValue(*value, is_value_nan); | 7888 date->SetValue(*value, is_value_nan); |
7869 return *value; | 7889 return *value; |
7870 } | 7890 } |
7871 | 7891 |
7872 | 7892 |
7873 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { | 7893 static Handle<JSObject> NewSloppyArguments(Isolate* isolate, |
7874 HandleScope scope(isolate); | 7894 Handle<JSFunction> callee, |
7875 ASSERT(args.length() == 3); | 7895 Object** parameters, |
7876 | 7896 int argument_count) { |
7877 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | |
7878 Object** parameters = reinterpret_cast<Object**>(args[1]); | |
7879 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | |
7880 | |
7881 Handle<JSObject> result = | 7897 Handle<JSObject> result = |
7882 isolate->factory()->NewArgumentsObject(callee, argument_count); | 7898 isolate->factory()->NewArgumentsObject(callee, argument_count); |
| 7899 |
7883 // Allocate the elements if needed. | 7900 // Allocate the elements if needed. |
7884 int parameter_count = callee->shared()->formal_parameter_count(); | 7901 int parameter_count = callee->shared()->formal_parameter_count(); |
7885 if (argument_count > 0) { | 7902 if (argument_count > 0) { |
7886 if (parameter_count > 0) { | 7903 if (parameter_count > 0) { |
7887 int mapped_count = Min(argument_count, parameter_count); | 7904 int mapped_count = Min(argument_count, parameter_count); |
7888 Handle<FixedArray> parameter_map = | 7905 Handle<FixedArray> parameter_map = |
7889 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); | 7906 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); |
7890 parameter_map->set_map( | 7907 parameter_map->set_map( |
7891 isolate->heap()->sloppy_arguments_elements_map()); | 7908 isolate->heap()->sloppy_arguments_elements_map()); |
7892 | 7909 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7953 // If there is no aliasing, the arguments object elements are not | 7970 // If there is no aliasing, the arguments object elements are not |
7954 // special in any way. | 7971 // special in any way. |
7955 Handle<FixedArray> elements = | 7972 Handle<FixedArray> elements = |
7956 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); | 7973 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); |
7957 result->set_elements(*elements); | 7974 result->set_elements(*elements); |
7958 for (int i = 0; i < argument_count; ++i) { | 7975 for (int i = 0; i < argument_count; ++i) { |
7959 elements->set(i, *(parameters - i - 1)); | 7976 elements->set(i, *(parameters - i - 1)); |
7960 } | 7977 } |
7961 } | 7978 } |
7962 } | 7979 } |
7963 return *result; | 7980 return result; |
| 7981 } |
| 7982 |
| 7983 |
| 7984 static Handle<JSObject> NewStrictArguments(Isolate* isolate, |
| 7985 Handle<JSFunction> callee, |
| 7986 Object** parameters, |
| 7987 int argument_count) { |
| 7988 Handle<JSObject> result = |
| 7989 isolate->factory()->NewArgumentsObject(callee, argument_count); |
| 7990 |
| 7991 if (argument_count > 0) { |
| 7992 Handle<FixedArray> array = |
| 7993 isolate->factory()->NewUninitializedFixedArray(argument_count); |
| 7994 DisallowHeapAllocation no_gc; |
| 7995 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
| 7996 for (int i = 0; i < argument_count; i++) { |
| 7997 array->set(i, *--parameters, mode); |
| 7998 } |
| 7999 result->set_elements(*array); |
| 8000 } |
| 8001 return result; |
| 8002 } |
| 8003 |
| 8004 |
| 8005 RUNTIME_FUNCTION(Runtime_NewArguments) { |
| 8006 HandleScope scope(isolate); |
| 8007 ASSERT(args.length() == 1); |
| 8008 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
| 8009 JavaScriptFrameIterator it(isolate); |
| 8010 |
| 8011 // Find the frame that holds the actual arguments passed to the function. |
| 8012 it.AdvanceToArgumentsFrame(); |
| 8013 JavaScriptFrame* frame = it.frame(); |
| 8014 |
| 8015 // Determine parameter location on the stack and dispatch on language mode. |
| 8016 int argument_count = frame->GetArgumentsLength(); |
| 8017 Object** parameters = reinterpret_cast<Object**>(frame->GetParameterSlot(-1)); |
| 8018 return callee->shared()->strict_mode() == STRICT |
| 8019 ? *NewStrictArguments(isolate, callee, parameters, argument_count) |
| 8020 : *NewSloppyArguments(isolate, callee, parameters, argument_count); |
| 8021 } |
| 8022 |
| 8023 |
| 8024 RUNTIME_FUNCTION(Runtime_NewSloppyArguments) { |
| 8025 HandleScope scope(isolate); |
| 8026 ASSERT(args.length() == 3); |
| 8027 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
| 8028 Object** parameters = reinterpret_cast<Object**>(args[1]); |
| 8029 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
| 8030 return *NewSloppyArguments(isolate, callee, parameters, argument_count); |
7964 } | 8031 } |
7965 | 8032 |
7966 | 8033 |
7967 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { | 8034 RUNTIME_FUNCTION(Runtime_NewStrictArguments) { |
7968 HandleScope scope(isolate); | 8035 HandleScope scope(isolate); |
7969 ASSERT(args.length() == 3); | 8036 ASSERT(args.length() == 3); |
7970 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 8037 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
7971 Object** parameters = reinterpret_cast<Object**>(args[1]); | 8038 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7972 CONVERT_SMI_ARG_CHECKED(length, 2); | 8039 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
7973 | 8040 return *NewStrictArguments(isolate, callee, parameters, argument_count); |
7974 Handle<JSObject> result = | |
7975 isolate->factory()->NewArgumentsObject(callee, length); | |
7976 | |
7977 if (length > 0) { | |
7978 Handle<FixedArray> array = | |
7979 isolate->factory()->NewUninitializedFixedArray(length); | |
7980 DisallowHeapAllocation no_gc; | |
7981 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | |
7982 for (int i = 0; i < length; i++) { | |
7983 array->set(i, *--parameters, mode); | |
7984 } | |
7985 result->set_elements(*array); | |
7986 } | |
7987 return *result; | |
7988 } | 8041 } |
7989 | 8042 |
7990 | 8043 |
7991 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { | 8044 RUNTIME_FUNCTION(Runtime_NewClosureFromStubFailure) { |
7992 HandleScope scope(isolate); | 8045 HandleScope scope(isolate); |
7993 ASSERT(args.length() == 1); | 8046 ASSERT(args.length() == 1); |
7994 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 8047 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
7995 Handle<Context> context(isolate->context()); | 8048 Handle<Context> context(isolate->context()); |
7996 PretenureFlag pretenure_flag = NOT_TENURED; | 8049 PretenureFlag pretenure_flag = NOT_TENURED; |
7997 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8050 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8454 return isolate->heap()->undefined_value(); | 8507 return isolate->heap()->undefined_value(); |
8455 } | 8508 } |
8456 | 8509 |
8457 | 8510 |
8458 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { | 8511 RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { |
8459 HandleScope scope(isolate); | 8512 HandleScope scope(isolate); |
8460 ASSERT(args.length() == 1); | 8513 ASSERT(args.length() == 1); |
8461 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8514 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8462 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 8515 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
8463 | 8516 |
| 8517 // TODO(turbofan): Deoptimization is not supported yet. |
| 8518 if (function->code()->is_turbofanned() && !FLAG_turbo_deoptimization) { |
| 8519 return isolate->heap()->undefined_value(); |
| 8520 } |
| 8521 |
8464 Deoptimizer::DeoptimizeFunction(*function); | 8522 Deoptimizer::DeoptimizeFunction(*function); |
8465 | 8523 |
8466 return isolate->heap()->undefined_value(); | 8524 return isolate->heap()->undefined_value(); |
8467 } | 8525 } |
8468 | 8526 |
8469 | 8527 |
8470 RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { | 8528 RUNTIME_FUNCTION(Runtime_ClearFunctionTypeFeedback) { |
8471 HandleScope scope(isolate); | 8529 HandleScope scope(isolate); |
8472 ASSERT(args.length() == 1); | 8530 ASSERT(args.length() == 1); |
8473 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8531 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8563 } | 8621 } |
8564 if (FLAG_always_opt) { | 8622 if (FLAG_always_opt) { |
8565 // We may have always opt, but that is more best-effort than a real | 8623 // We may have always opt, but that is more best-effort than a real |
8566 // promise, so we still say "no" if it is not optimized. | 8624 // promise, so we still say "no" if it is not optimized. |
8567 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". | 8625 return function->IsOptimized() ? Smi::FromInt(3) // 3 == "always". |
8568 : Smi::FromInt(2); // 2 == "no". | 8626 : Smi::FromInt(2); // 2 == "no". |
8569 } | 8627 } |
8570 if (FLAG_deopt_every_n_times) { | 8628 if (FLAG_deopt_every_n_times) { |
8571 return Smi::FromInt(6); // 6 == "maybe deopted". | 8629 return Smi::FromInt(6); // 6 == "maybe deopted". |
8572 } | 8630 } |
| 8631 if (function->IsOptimized() && function->code()->is_turbofanned()) { |
| 8632 return Smi::FromInt(7); // 7 == "TurboFan compiler". |
| 8633 } |
8573 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8634 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
8574 : Smi::FromInt(2); // 2 == "no". | 8635 : Smi::FromInt(2); // 2 == "no". |
8575 } | 8636 } |
8576 | 8637 |
8577 | 8638 |
8578 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { | 8639 RUNTIME_FUNCTION(Runtime_UnblockConcurrentRecompilation) { |
8579 ASSERT(args.length() == 0); | 8640 ASSERT(args.length() == 0); |
8580 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); | 8641 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); |
8581 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); | 8642 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); |
8582 isolate->optimizing_compiler_thread()->Unblock(); | 8643 isolate->optimizing_compiler_thread()->Unblock(); |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8870 result->global_object()->set_global_context(*result); | 8931 result->global_object()->set_global_context(*result); |
8871 return *result; | 8932 return *result; |
8872 } | 8933 } |
8873 | 8934 |
8874 | 8935 |
8875 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { | 8936 RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
8876 HandleScope scope(isolate); | 8937 HandleScope scope(isolate); |
8877 ASSERT(args.length() == 1); | 8938 ASSERT(args.length() == 1); |
8878 | 8939 |
8879 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8940 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 8941 |
| 8942 ASSERT(function->context() == isolate->context()); |
8880 int length = function->shared()->scope_info()->ContextLength(); | 8943 int length = function->shared()->scope_info()->ContextLength(); |
8881 return *isolate->factory()->NewFunctionContext(length, function); | 8944 return *isolate->factory()->NewFunctionContext(length, function); |
8882 } | 8945 } |
8883 | 8946 |
8884 | 8947 |
8885 RUNTIME_FUNCTION(Runtime_PushWithContext) { | 8948 RUNTIME_FUNCTION(Runtime_PushWithContext) { |
8886 HandleScope scope(isolate); | 8949 HandleScope scope(isolate); |
8887 ASSERT(args.length() == 2); | 8950 ASSERT(args.length() == 2); |
8888 Handle<JSReceiver> extension_object; | 8951 Handle<JSReceiver> extension_object; |
8889 if (args[0]->IsJSReceiver()) { | 8952 if (args[0]->IsJSReceiver()) { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9338 object = Handle<JSReceiver>(context->global_object()); | 9401 object = Handle<JSReceiver>(context->global_object()); |
9339 } | 9402 } |
9340 | 9403 |
9341 RETURN_FAILURE_ON_EXCEPTION( | 9404 RETURN_FAILURE_ON_EXCEPTION( |
9342 isolate, Object::SetProperty(object, name, value, strict_mode)); | 9405 isolate, Object::SetProperty(object, name, value, strict_mode)); |
9343 | 9406 |
9344 return *value; | 9407 return *value; |
9345 } | 9408 } |
9346 | 9409 |
9347 | 9410 |
| 9411 RUNTIME_FUNCTION(Runtime_LoadContextRelative) { |
| 9412 SealHandleScope shs(isolate); |
| 9413 ASSERT(args.length() == 3); |
| 9414 CONVERT_ARG_CHECKED(Context, context, 0); |
| 9415 CONVERT_SMI_ARG_CHECKED(depth, 1); |
| 9416 CONVERT_SMI_ARG_CHECKED(index, 2); |
| 9417 while (depth-- > 0) { |
| 9418 context = context->previous(); |
| 9419 ASSERT(context->IsContext()); |
| 9420 } |
| 9421 return context->get(index); |
| 9422 } |
| 9423 |
| 9424 |
| 9425 RUNTIME_FUNCTION(Runtime_StoreContextRelative) { |
| 9426 SealHandleScope shs(isolate); |
| 9427 ASSERT(args.length() == 4); |
| 9428 CONVERT_ARG_CHECKED(Context, context, 0); |
| 9429 CONVERT_SMI_ARG_CHECKED(depth, 1); |
| 9430 CONVERT_SMI_ARG_CHECKED(index, 2); |
| 9431 CONVERT_ARG_CHECKED(Object, value, 3); |
| 9432 while (depth-- > 0) { |
| 9433 context = context->previous(); |
| 9434 ASSERT(context->IsContext()); |
| 9435 } |
| 9436 context->set(index, value); |
| 9437 return isolate->heap()->undefined_value(); |
| 9438 } |
| 9439 |
| 9440 |
9348 RUNTIME_FUNCTION(Runtime_Throw) { | 9441 RUNTIME_FUNCTION(Runtime_Throw) { |
9349 HandleScope scope(isolate); | 9442 HandleScope scope(isolate); |
9350 ASSERT(args.length() == 1); | 9443 ASSERT(args.length() == 1); |
9351 | 9444 |
9352 return isolate->Throw(args[0]); | 9445 return isolate->Throw(args[0]); |
9353 } | 9446 } |
9354 | 9447 |
9355 | 9448 |
9356 RUNTIME_FUNCTION(Runtime_ReThrow) { | 9449 RUNTIME_FUNCTION(Runtime_ReThrow) { |
9357 HandleScope scope(isolate); | 9450 HandleScope scope(isolate); |
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11098 JavaScriptFrame* frame) { | 11191 JavaScriptFrame* frame) { |
11099 SaveContext* save = isolate->save_context(); | 11192 SaveContext* save = isolate->save_context(); |
11100 while (save != NULL && !save->IsBelowFrame(frame)) { | 11193 while (save != NULL && !save->IsBelowFrame(frame)) { |
11101 save = save->prev(); | 11194 save = save->prev(); |
11102 } | 11195 } |
11103 ASSERT(save != NULL); | 11196 ASSERT(save != NULL); |
11104 return save; | 11197 return save; |
11105 } | 11198 } |
11106 | 11199 |
11107 | 11200 |
| 11201 RUNTIME_FUNCTION(Runtime_IsOptimized) { |
| 11202 SealHandleScope shs(isolate); |
| 11203 ASSERT(args.length() == 0); |
| 11204 JavaScriptFrameIterator it(isolate); |
| 11205 JavaScriptFrame* frame = it.frame(); |
| 11206 return isolate->heap()->ToBoolean(frame->is_optimized()); |
| 11207 } |
| 11208 |
| 11209 |
11108 // Return an array with frame details | 11210 // Return an array with frame details |
11109 // args[0]: number: break id | 11211 // args[0]: number: break id |
11110 // args[1]: number: frame index | 11212 // args[1]: number: frame index |
11111 // | 11213 // |
11112 // The array returned contains the following information: | 11214 // The array returned contains the following information: |
11113 // 0: Frame id | 11215 // 0: Frame id |
11114 // 1: Receiver | 11216 // 1: Receiver |
11115 // 2: Function | 11217 // 2: Function |
11116 // 3: Argument count | 11218 // 3: Argument count |
11117 // 4: Local count | 11219 // 4: Local count |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11200 if (local < local_count) { | 11302 if (local < local_count) { |
11201 // Get the context containing declarations. | 11303 // Get the context containing declarations. |
11202 Handle<Context> context( | 11304 Handle<Context> context( |
11203 Context::cast(it.frame()->context())->declaration_context()); | 11305 Context::cast(it.frame()->context())->declaration_context()); |
11204 for (; i < scope_info->LocalCount(); ++i) { | 11306 for (; i < scope_info->LocalCount(); ++i) { |
11205 if (scope_info->LocalIsSynthetic(i)) | 11307 if (scope_info->LocalIsSynthetic(i)) |
11206 continue; | 11308 continue; |
11207 Handle<String> name(scope_info->LocalName(i)); | 11309 Handle<String> name(scope_info->LocalName(i)); |
11208 VariableMode mode; | 11310 VariableMode mode; |
11209 InitializationFlag init_flag; | 11311 InitializationFlag init_flag; |
| 11312 MaybeAssignedFlag maybe_assigned_flag; |
11210 locals->set(local * 2, *name); | 11313 locals->set(local * 2, *name); |
11211 int context_slot_index = | 11314 int context_slot_index = ScopeInfo::ContextSlotIndex( |
11212 ScopeInfo::ContextSlotIndex(scope_info, name, &mode, &init_flag); | 11315 scope_info, name, &mode, &init_flag, &maybe_assigned_flag); |
11213 Object* value = context->get(context_slot_index); | 11316 Object* value = context->get(context_slot_index); |
11214 locals->set(local * 2 + 1, value); | 11317 locals->set(local * 2 + 1, value); |
11215 local++; | 11318 local++; |
11216 } | 11319 } |
11217 } | 11320 } |
11218 | 11321 |
11219 // Check whether this frame is positioned at return. If not top | 11322 // Check whether this frame is positioned at return. If not top |
11220 // frame or if the frame is optimized it cannot be at a return. | 11323 // frame or if the frame is optimized it cannot be at a return. |
11221 bool at_return = false; | 11324 bool at_return = false; |
11222 if (!is_optimized && index == 0) { | 11325 if (!is_optimized && index == 0) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11375 details->set(kFrameDetailsReceiverIndex, *receiver); | 11478 details->set(kFrameDetailsReceiverIndex, *receiver); |
11376 | 11479 |
11377 ASSERT_EQ(details_size, details_index); | 11480 ASSERT_EQ(details_size, details_index); |
11378 return *isolate->factory()->NewJSArrayWithElements(details); | 11481 return *isolate->factory()->NewJSArrayWithElements(details); |
11379 } | 11482 } |
11380 | 11483 |
11381 | 11484 |
11382 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, | 11485 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, |
11383 Handle<String> parameter_name) { | 11486 Handle<String> parameter_name) { |
11384 VariableMode mode; | 11487 VariableMode mode; |
11385 InitializationFlag flag; | 11488 InitializationFlag init_flag; |
11386 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &flag) != -1; | 11489 MaybeAssignedFlag maybe_assigned_flag; |
| 11490 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &init_flag, |
| 11491 &maybe_assigned_flag) != -1; |
11387 } | 11492 } |
11388 | 11493 |
11389 | 11494 |
11390 // Create a plain JSObject which materializes the local scope for the specified | 11495 // Create a plain JSObject which materializes the local scope for the specified |
11391 // frame. | 11496 // frame. |
11392 MUST_USE_RESULT | 11497 MUST_USE_RESULT |
11393 static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( | 11498 static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( |
11394 Isolate* isolate, | 11499 Isolate* isolate, |
11395 Handle<JSObject> target, | 11500 Handle<JSObject> target, |
11396 Handle<JSFunction> function, | 11501 Handle<JSFunction> function, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11548 static bool SetContextLocalValue(Isolate* isolate, | 11653 static bool SetContextLocalValue(Isolate* isolate, |
11549 Handle<ScopeInfo> scope_info, | 11654 Handle<ScopeInfo> scope_info, |
11550 Handle<Context> context, | 11655 Handle<Context> context, |
11551 Handle<String> variable_name, | 11656 Handle<String> variable_name, |
11552 Handle<Object> new_value) { | 11657 Handle<Object> new_value) { |
11553 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { | 11658 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { |
11554 Handle<String> next_name(scope_info->ContextLocalName(i)); | 11659 Handle<String> next_name(scope_info->ContextLocalName(i)); |
11555 if (String::Equals(variable_name, next_name)) { | 11660 if (String::Equals(variable_name, next_name)) { |
11556 VariableMode mode; | 11661 VariableMode mode; |
11557 InitializationFlag init_flag; | 11662 InitializationFlag init_flag; |
11558 int context_index = | 11663 MaybeAssignedFlag maybe_assigned_flag; |
11559 ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &init_flag); | 11664 int context_index = ScopeInfo::ContextSlotIndex( |
| 11665 scope_info, next_name, &mode, &init_flag, &maybe_assigned_flag); |
11560 context->set(context_index, *new_value); | 11666 context->set(context_index, *new_value); |
11561 return true; | 11667 return true; |
11562 } | 11668 } |
11563 } | 11669 } |
11564 | 11670 |
11565 return false; | 11671 return false; |
11566 } | 11672 } |
11567 | 11673 |
11568 | 11674 |
11569 static bool SetLocalVariableValue(Isolate* isolate, | 11675 static bool SetLocalVariableValue(Isolate* isolate, |
(...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15015 RUNTIME_FUNCTION(Runtime_NormalizeElements) { | 15121 RUNTIME_FUNCTION(Runtime_NormalizeElements) { |
15016 HandleScope scope(isolate); | 15122 HandleScope scope(isolate); |
15017 ASSERT(args.length() == 1); | 15123 ASSERT(args.length() == 1); |
15018 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 15124 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
15019 JSObject::NormalizeElements(array); | 15125 JSObject::NormalizeElements(array); |
15020 return *array; | 15126 return *array; |
15021 } | 15127 } |
15022 | 15128 |
15023 | 15129 |
15024 RUNTIME_FUNCTION(Runtime_MaxSmi) { | 15130 RUNTIME_FUNCTION(Runtime_MaxSmi) { |
| 15131 SealHandleScope shs(isolate); |
15025 ASSERT(args.length() == 0); | 15132 ASSERT(args.length() == 0); |
15026 return Smi::FromInt(Smi::kMaxValue); | 15133 return Smi::FromInt(Smi::kMaxValue); |
15027 } | 15134 } |
15028 | 15135 |
15029 | 15136 |
| 15137 // TODO(dcarney): remove this function when TurboFan supports it. |
| 15138 // Takes the object to be iterated over and the result of GetPropertyNamesFast |
| 15139 // Returns pair (cache_array, cache_type). |
| 15140 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInInit) { |
| 15141 SealHandleScope scope(isolate); |
| 15142 ASSERT(args.length() == 2); |
| 15143 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. |
| 15144 // Not worth creating a macro atm as this function should be removed. |
| 15145 if (!args[0]->IsJSReceiver() || |
| 15146 !args[1]->IsObject()) { |
| 15147 return MakePair(isolate->ThrowIllegalOperation(), |
| 15148 isolate->heap()->undefined_value()); |
| 15149 } |
| 15150 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
| 15151 Handle<Object> cache_type = args.at<Object>(1); |
| 15152 if (cache_type->IsMap()) { |
| 15153 // Enum cache case. |
| 15154 if (Map::EnumLengthBits::decode( |
| 15155 Map::cast(*cache_type)->bit_field3()) == 0) { |
| 15156 // 0 length enum. |
| 15157 // Can't handle this case in the graph builder, |
| 15158 // so transform it into the empty fixed array case. |
| 15159 return MakePair(isolate->heap()->empty_fixed_array(), |
| 15160 Smi::FromInt(1)); |
| 15161 } |
| 15162 return MakePair(object->map()->instance_descriptors()->GetEnumCache(), |
| 15163 *cache_type); |
| 15164 } else { |
| 15165 // FixedArray case. |
| 15166 Smi* new_cache_type = Smi::FromInt(object->IsJSProxy() ? 0 : 1); |
| 15167 return MakePair(*Handle<FixedArray>::cast(cache_type), |
| 15168 new_cache_type); |
| 15169 } |
| 15170 } |
| 15171 |
| 15172 |
| 15173 // TODO(dcarney): remove this function when TurboFan supports it. |
| 15174 RUNTIME_FUNCTION(Runtime_ForInCacheArrayLength) { |
| 15175 SealHandleScope shs(isolate); |
| 15176 ASSERT(args.length() == 2); |
| 15177 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 0); |
| 15178 CONVERT_ARG_HANDLE_CHECKED(FixedArray, array, 1); |
| 15179 int length = 0; |
| 15180 if (cache_type->IsMap()) { |
| 15181 length = Map::cast(*cache_type)->EnumLength(); |
| 15182 } else { |
| 15183 ASSERT(cache_type->IsSmi()); |
| 15184 length = array->length(); |
| 15185 } |
| 15186 return Smi::FromInt(length); |
| 15187 } |
| 15188 |
| 15189 |
| 15190 // TODO(dcarney): remove this function when TurboFan supports it. |
| 15191 // Takes (the object to be iterated over, |
| 15192 // cache_array from ForInInit, |
| 15193 // cache_type from ForInInit, |
| 15194 // the current index) |
| 15195 // Returns pair (array[index], needs_filtering). |
| 15196 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInNext) { |
| 15197 SealHandleScope scope(isolate); |
| 15198 ASSERT(args.length() == 4); |
| 15199 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. |
| 15200 // Not worth creating a macro atm as this function should be removed. |
| 15201 if (!args[0]->IsJSReceiver() || |
| 15202 !args[1]->IsFixedArray() || |
| 15203 !args[2]->IsObject() || |
| 15204 !args[3]->IsSmi()) { |
| 15205 return MakePair(isolate->ThrowIllegalOperation(), |
| 15206 isolate->heap()->undefined_value()); |
| 15207 } |
| 15208 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
| 15209 Handle<FixedArray> array = args.at<FixedArray>(1); |
| 15210 Handle<Object> cache_type = args.at<Object>(2); |
| 15211 int index = args.smi_at(3); |
| 15212 // Figure out first if a slow check is needed for this object. |
| 15213 bool slow_check_needed = false; |
| 15214 if (cache_type->IsMap()) { |
| 15215 if (object->map() != Map::cast(*cache_type)) { |
| 15216 // Object transitioned. Need slow check. |
| 15217 slow_check_needed = true; |
| 15218 } |
| 15219 } else { |
| 15220 // No slow check needed for proxies. |
| 15221 slow_check_needed = Smi::cast(*cache_type)->value() == 1; |
| 15222 } |
| 15223 return MakePair(array->get(index), |
| 15224 isolate->heap()->ToBoolean(slow_check_needed)); |
| 15225 } |
| 15226 |
| 15227 |
| 15228 // ---------------------------------------------------------------------------- |
| 15229 // Reference implementation for inlined runtime functions. Only used when the |
| 15230 // compiler does not support a certain intrinsic. Don't optimize these, but |
| 15231 // implement the intrinsic in the respective compiler instead. |
| 15232 |
| 15233 // TODO(mstarzinger): These are place-holder stubs for TurboFan and will |
| 15234 // eventually all have a C++ implementation and this macro will be gone. |
| 15235 #define U(name) \ |
| 15236 RUNTIME_FUNCTION(RuntimeReference_##name) { \ |
| 15237 UNIMPLEMENTED(); \ |
| 15238 return NULL; \ |
| 15239 } |
| 15240 |
| 15241 U(IsStringWrapperSafeForDefaultValueOf) |
| 15242 U(GeneratorNext) |
| 15243 U(GeneratorThrow) |
| 15244 U(DebugBreakInOptimizedCode) |
| 15245 |
| 15246 #undef U |
| 15247 |
| 15248 |
| 15249 RUNTIME_FUNCTION(RuntimeReference_IsSmi) { |
| 15250 SealHandleScope shs(isolate); |
| 15251 ASSERT(args.length() == 1); |
| 15252 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15253 return isolate->heap()->ToBoolean(obj->IsSmi()); |
| 15254 } |
| 15255 |
| 15256 |
| 15257 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { |
| 15258 SealHandleScope shs(isolate); |
| 15259 ASSERT(args.length() == 1); |
| 15260 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15261 return isolate->heap()->ToBoolean( |
| 15262 obj->IsSmi() && Smi::cast(obj)->value() >= 0); |
| 15263 } |
| 15264 |
| 15265 |
| 15266 RUNTIME_FUNCTION(RuntimeReference_IsArray) { |
| 15267 SealHandleScope shs(isolate); |
| 15268 ASSERT(args.length() == 1); |
| 15269 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15270 return isolate->heap()->ToBoolean(obj->IsJSArray()); |
| 15271 } |
| 15272 |
| 15273 |
| 15274 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { |
| 15275 SealHandleScope shs(isolate); |
| 15276 ASSERT(args.length() == 1); |
| 15277 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15278 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
| 15279 } |
| 15280 |
| 15281 |
| 15282 RUNTIME_FUNCTION(RuntimeReference_IsConstructCall) { |
| 15283 SealHandleScope shs(isolate); |
| 15284 ASSERT(args.length() == 0); |
| 15285 JavaScriptFrameIterator it(isolate); |
| 15286 JavaScriptFrame* frame = it.frame(); |
| 15287 return isolate->heap()->ToBoolean(frame->IsConstructor()); |
| 15288 } |
| 15289 |
| 15290 |
| 15291 RUNTIME_FUNCTION(RuntimeReference_CallFunction) { |
| 15292 SealHandleScope shs(isolate); |
| 15293 return __RT_impl_Runtime_Call(args, isolate); |
| 15294 } |
| 15295 |
| 15296 |
| 15297 RUNTIME_FUNCTION(RuntimeReference_ArgumentsLength) { |
| 15298 SealHandleScope shs(isolate); |
| 15299 ASSERT(args.length() == 0); |
| 15300 JavaScriptFrameIterator it(isolate); |
| 15301 JavaScriptFrame* frame = it.frame(); |
| 15302 return Smi::FromInt(frame->GetArgumentsLength()); |
| 15303 } |
| 15304 |
| 15305 |
| 15306 RUNTIME_FUNCTION(RuntimeReference_Arguments) { |
| 15307 SealHandleScope shs(isolate); |
| 15308 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
| 15309 } |
| 15310 |
| 15311 |
| 15312 RUNTIME_FUNCTION(RuntimeReference_ValueOf) { |
| 15313 SealHandleScope shs(isolate); |
| 15314 ASSERT(args.length() == 1); |
| 15315 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15316 if (!obj->IsJSValue()) return obj; |
| 15317 return JSValue::cast(obj)->value(); |
| 15318 } |
| 15319 |
| 15320 |
| 15321 RUNTIME_FUNCTION(RuntimeReference_SetValueOf) { |
| 15322 SealHandleScope shs(isolate); |
| 15323 ASSERT(args.length() == 2); |
| 15324 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15325 CONVERT_ARG_CHECKED(Object, value, 1); |
| 15326 if (!obj->IsJSValue()) return value; |
| 15327 JSValue::cast(obj)->set_value(value); |
| 15328 return value; |
| 15329 } |
| 15330 |
| 15331 |
| 15332 RUNTIME_FUNCTION(RuntimeReference_DateField) { |
| 15333 SealHandleScope shs(isolate); |
| 15334 ASSERT(args.length() == 2); |
| 15335 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15336 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15337 if (!obj->IsJSDate()) { |
| 15338 HandleScope scope(isolate); |
| 15339 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 15340 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 15341 } |
| 15342 JSDate* date = JSDate::cast(obj); |
| 15343 if (index == 0) return date->value(); |
| 15344 return JSDate::GetField(date, Smi::FromInt(index)); |
| 15345 } |
| 15346 |
| 15347 |
| 15348 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { |
| 15349 SealHandleScope shs(isolate); |
| 15350 return __RT_impl_Runtime_CharFromCode(args, isolate); |
| 15351 } |
| 15352 |
| 15353 |
| 15354 RUNTIME_FUNCTION(RuntimeReference_StringCharAt) { |
| 15355 SealHandleScope shs(isolate); |
| 15356 ASSERT(args.length() == 2); |
| 15357 if (!args[0]->IsString()) return Smi::FromInt(0); |
| 15358 if (!args[1]->IsNumber()) return Smi::FromInt(0); |
| 15359 if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string(); |
| 15360 Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
| 15361 if (code->IsNaN()) return isolate->heap()->empty_string(); |
| 15362 return __RT_impl_Runtime_CharFromCode(Arguments(1, &code), isolate); |
| 15363 } |
| 15364 |
| 15365 |
| 15366 RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) { |
| 15367 SealHandleScope shs(isolate); |
| 15368 ASSERT(args.length() == 3); |
| 15369 CONVERT_ARG_CHECKED(SeqOneByteString, string, 0); |
| 15370 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15371 CONVERT_SMI_ARG_CHECKED(value, 2); |
| 15372 string->SeqOneByteStringSet(index, value); |
| 15373 return string; |
| 15374 } |
| 15375 |
| 15376 |
| 15377 RUNTIME_FUNCTION(RuntimeReference_TwoByteSeqStringSetChar) { |
| 15378 SealHandleScope shs(isolate); |
| 15379 ASSERT(args.length() == 3); |
| 15380 CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0); |
| 15381 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15382 CONVERT_SMI_ARG_CHECKED(value, 2); |
| 15383 string->SeqTwoByteStringSet(index, value); |
| 15384 return string; |
| 15385 } |
| 15386 |
| 15387 |
| 15388 RUNTIME_FUNCTION(RuntimeReference_ObjectEquals) { |
| 15389 SealHandleScope shs(isolate); |
| 15390 ASSERT(args.length() == 2); |
| 15391 CONVERT_ARG_CHECKED(Object, obj1, 0); |
| 15392 CONVERT_ARG_CHECKED(Object, obj2, 1); |
| 15393 return isolate->heap()->ToBoolean(obj1 == obj2); |
| 15394 } |
| 15395 |
| 15396 |
| 15397 RUNTIME_FUNCTION(RuntimeReference_IsObject) { |
| 15398 SealHandleScope shs(isolate); |
| 15399 ASSERT(args.length() == 1); |
| 15400 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15401 if (!obj->IsHeapObject()) return isolate->heap()->false_value(); |
| 15402 if (obj->IsNull()) return isolate->heap()->true_value(); |
| 15403 if (obj->IsUndetectableObject()) return isolate->heap()->false_value(); |
| 15404 Map* map = HeapObject::cast(obj)->map(); |
| 15405 bool is_non_callable_spec_object = |
| 15406 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && |
| 15407 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE; |
| 15408 return isolate->heap()->ToBoolean(is_non_callable_spec_object); |
| 15409 } |
| 15410 |
| 15411 |
| 15412 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
| 15413 SealHandleScope shs(isolate); |
| 15414 ASSERT(args.length() == 1); |
| 15415 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15416 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
| 15417 } |
| 15418 |
| 15419 |
| 15420 RUNTIME_FUNCTION(RuntimeReference_IsUndetectableObject) { |
| 15421 SealHandleScope shs(isolate); |
| 15422 ASSERT(args.length() == 1); |
| 15423 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15424 return isolate->heap()->ToBoolean(obj->IsUndetectableObject()); |
| 15425 } |
| 15426 |
| 15427 |
| 15428 RUNTIME_FUNCTION(RuntimeReference_IsSpecObject) { |
| 15429 SealHandleScope shs(isolate); |
| 15430 ASSERT(args.length() == 1); |
| 15431 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15432 return isolate->heap()->ToBoolean(obj->IsSpecObject()); |
| 15433 } |
| 15434 |
| 15435 |
| 15436 RUNTIME_FUNCTION(RuntimeReference_MathPow) { |
| 15437 SealHandleScope shs(isolate); |
| 15438 return __RT_impl_Runtime_MathPowSlow(args, isolate); |
| 15439 } |
| 15440 |
| 15441 |
| 15442 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { |
| 15443 SealHandleScope shs(isolate); |
| 15444 ASSERT(args.length() == 1); |
| 15445 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15446 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); |
| 15447 HeapNumber* number = HeapNumber::cast(obj); |
| 15448 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
| 15449 } |
| 15450 |
| 15451 |
| 15452 RUNTIME_FUNCTION(RuntimeReference_HasCachedArrayIndex) { |
| 15453 SealHandleScope shs(isolate); |
| 15454 ASSERT(args.length() == 1); |
| 15455 return isolate->heap()->false_value(); |
| 15456 } |
| 15457 |
| 15458 |
| 15459 RUNTIME_FUNCTION(RuntimeReference_GetCachedArrayIndex) { |
| 15460 SealHandleScope shs(isolate); |
| 15461 ASSERT(args.length() == 1); |
| 15462 return isolate->heap()->undefined_value(); |
| 15463 } |
| 15464 |
| 15465 |
| 15466 RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) { |
| 15467 SealHandleScope shs(isolate); |
| 15468 ASSERT(args.length() == 2); |
| 15469 return isolate->heap()->undefined_value(); |
| 15470 } |
| 15471 |
| 15472 |
| 15473 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { |
| 15474 SealHandleScope shs(isolate); |
| 15475 ASSERT(args.length() == 1); |
| 15476 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15477 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
| 15478 return JSReceiver::cast(obj)->class_name(); |
| 15479 } |
| 15480 |
| 15481 |
| 15482 RUNTIME_FUNCTION(RuntimeReference_StringCharCodeAt) { |
| 15483 SealHandleScope shs(isolate); |
| 15484 ASSERT(args.length() == 2); |
| 15485 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
| 15486 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
| 15487 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
| 15488 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
| 15489 } |
| 15490 |
| 15491 |
| 15492 RUNTIME_FUNCTION(RuntimeReference_StringAdd) { |
| 15493 SealHandleScope shs(isolate); |
| 15494 return __RT_impl_Runtime_StringAdd(args, isolate); |
| 15495 } |
| 15496 |
| 15497 |
| 15498 RUNTIME_FUNCTION(RuntimeReference_SubString) { |
| 15499 SealHandleScope shs(isolate); |
| 15500 return __RT_impl_Runtime_SubString(args, isolate); |
| 15501 } |
| 15502 |
| 15503 |
| 15504 RUNTIME_FUNCTION(RuntimeReference_StringCompare) { |
| 15505 SealHandleScope shs(isolate); |
| 15506 return __RT_impl_Runtime_StringCompare(args, isolate); |
| 15507 } |
| 15508 |
| 15509 |
| 15510 RUNTIME_FUNCTION(RuntimeReference_RegExpExec) { |
| 15511 SealHandleScope shs(isolate); |
| 15512 return __RT_impl_Runtime_RegExpExecRT(args, isolate); |
| 15513 } |
| 15514 |
| 15515 |
| 15516 RUNTIME_FUNCTION(RuntimeReference_RegExpConstructResult) { |
| 15517 SealHandleScope shs(isolate); |
| 15518 return __RT_impl_Runtime_RegExpConstructResult(args, isolate); |
| 15519 } |
| 15520 |
| 15521 |
| 15522 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) { |
| 15523 HandleScope scope(isolate); |
| 15524 ASSERT(args.length() == 2); |
| 15525 CONVERT_SMI_ARG_CHECKED(id, 0); |
| 15526 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id); |
| 15527 return __RT_impl_Runtime_GetFromCache(args, isolate); |
| 15528 } |
| 15529 |
| 15530 |
| 15531 RUNTIME_FUNCTION(RuntimeReference_NumberToString) { |
| 15532 SealHandleScope shs(isolate); |
| 15533 return __RT_impl_Runtime_NumberToStringRT(args, isolate); |
| 15534 } |
| 15535 |
| 15536 |
| 15537 RUNTIME_FUNCTION(RuntimeReference_DebugIsActive) { |
| 15538 SealHandleScope shs(isolate); |
| 15539 return Smi::FromInt(isolate->debug()->is_active()); |
| 15540 } |
| 15541 |
| 15542 |
15030 // ---------------------------------------------------------------------------- | 15543 // ---------------------------------------------------------------------------- |
15031 // Implementation of Runtime | 15544 // Implementation of Runtime |
15032 | 15545 |
15033 #define F(name, number_of_args, result_size) \ | 15546 #define F(name, number_of_args, result_size) \ |
15034 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 15547 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
15035 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15548 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
15036 | 15549 |
15037 | 15550 |
15038 #define I(name, number_of_args, result_size) \ | 15551 #define I(name, number_of_args, result_size) \ |
15039 { Runtime::kInline##name, Runtime::INLINE, \ | 15552 { Runtime::kInline##name, Runtime::INLINE, "_" #name, \ |
15040 "_" #name, NULL, number_of_args, result_size }, | 15553 FUNCTION_ADDR(RuntimeReference_##name), number_of_args, result_size }, |
15041 | 15554 |
15042 | 15555 |
15043 #define IO(name, number_of_args, result_size) \ | 15556 #define IO(name, number_of_args, result_size) \ |
15044 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \ | 15557 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, "_" #name, \ |
15045 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15558 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
15046 | 15559 |
15047 | 15560 |
15048 static const Runtime::Function kIntrinsicFunctions[] = { | 15561 static const Runtime::Function kIntrinsicFunctions[] = { |
15049 RUNTIME_FUNCTION_LIST(F) | 15562 RUNTIME_FUNCTION_LIST(F) |
15050 INLINE_OPTIMIZED_FUNCTION_LIST(F) | 15563 INLINE_OPTIMIZED_FUNCTION_LIST(F) |
15051 INLINE_FUNCTION_LIST(I) | 15564 INLINE_FUNCTION_LIST(I) |
15052 INLINE_OPTIMIZED_FUNCTION_LIST(IO) | 15565 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
15053 }; | 15566 }; |
15054 | 15567 |
15055 #undef IO | 15568 #undef IO |
(...skipping 24 matching lines...) Expand all Loading... |
15080 int entry = heap->intrinsic_function_names()->FindEntry(name); | 15593 int entry = heap->intrinsic_function_names()->FindEntry(name); |
15081 if (entry != kNotFound) { | 15594 if (entry != kNotFound) { |
15082 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); | 15595 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); |
15083 int function_index = Smi::cast(smi_index)->value(); | 15596 int function_index = Smi::cast(smi_index)->value(); |
15084 return &(kIntrinsicFunctions[function_index]); | 15597 return &(kIntrinsicFunctions[function_index]); |
15085 } | 15598 } |
15086 return NULL; | 15599 return NULL; |
15087 } | 15600 } |
15088 | 15601 |
15089 | 15602 |
| 15603 const Runtime::Function* Runtime::FunctionForEntry(Address entry) { |
| 15604 for (size_t i = 0; i < sizeof(kIntrinsicFunctions); ++i) { |
| 15605 if (entry == kIntrinsicFunctions[i].entry) { |
| 15606 return &(kIntrinsicFunctions[i]); |
| 15607 } |
| 15608 } |
| 15609 return NULL; |
| 15610 } |
| 15611 |
| 15612 |
15090 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15613 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15091 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15614 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15092 } | 15615 } |
15093 | 15616 |
15094 } } // namespace v8::internal | 15617 } } // namespace v8::internal |
OLD | NEW |