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() || !args[1]->IsObject()) { |
| 15146 return MakePair(isolate->ThrowIllegalOperation(), |
| 15147 isolate->heap()->undefined_value()); |
| 15148 } |
| 15149 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
| 15150 Handle<Object> cache_type = args.at<Object>(1); |
| 15151 if (cache_type->IsMap()) { |
| 15152 // Enum cache case. |
| 15153 if (Map::EnumLengthBits::decode(Map::cast(*cache_type)->bit_field3()) == |
| 15154 0) { |
| 15155 // 0 length enum. |
| 15156 // Can't handle this case in the graph builder, |
| 15157 // so transform it into the empty fixed array case. |
| 15158 return MakePair(isolate->heap()->empty_fixed_array(), Smi::FromInt(1)); |
| 15159 } |
| 15160 return MakePair(object->map()->instance_descriptors()->GetEnumCache(), |
| 15161 *cache_type); |
| 15162 } else { |
| 15163 // FixedArray case. |
| 15164 Smi* new_cache_type = Smi::FromInt(object->IsJSProxy() ? 0 : 1); |
| 15165 return MakePair(*Handle<FixedArray>::cast(cache_type), new_cache_type); |
| 15166 } |
| 15167 } |
| 15168 |
| 15169 |
| 15170 // TODO(dcarney): remove this function when TurboFan supports it. |
| 15171 RUNTIME_FUNCTION(Runtime_ForInCacheArrayLength) { |
| 15172 SealHandleScope shs(isolate); |
| 15173 ASSERT(args.length() == 2); |
| 15174 CONVERT_ARG_HANDLE_CHECKED(Object, cache_type, 0); |
| 15175 CONVERT_ARG_HANDLE_CHECKED(FixedArray, array, 1); |
| 15176 int length = 0; |
| 15177 if (cache_type->IsMap()) { |
| 15178 length = Map::cast(*cache_type)->EnumLength(); |
| 15179 } else { |
| 15180 ASSERT(cache_type->IsSmi()); |
| 15181 length = array->length(); |
| 15182 } |
| 15183 return Smi::FromInt(length); |
| 15184 } |
| 15185 |
| 15186 |
| 15187 // TODO(dcarney): remove this function when TurboFan supports it. |
| 15188 // Takes (the object to be iterated over, |
| 15189 // cache_array from ForInInit, |
| 15190 // cache_type from ForInInit, |
| 15191 // the current index) |
| 15192 // Returns pair (array[index], needs_filtering). |
| 15193 RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInNext) { |
| 15194 SealHandleScope scope(isolate); |
| 15195 ASSERT(args.length() == 4); |
| 15196 // This simulates CONVERT_ARG_HANDLE_CHECKED for calls returning pairs. |
| 15197 // Not worth creating a macro atm as this function should be removed. |
| 15198 if (!args[0]->IsJSReceiver() || !args[1]->IsFixedArray() || |
| 15199 !args[2]->IsObject() || !args[3]->IsSmi()) { |
| 15200 return MakePair(isolate->ThrowIllegalOperation(), |
| 15201 isolate->heap()->undefined_value()); |
| 15202 } |
| 15203 Handle<JSReceiver> object = args.at<JSReceiver>(0); |
| 15204 Handle<FixedArray> array = args.at<FixedArray>(1); |
| 15205 Handle<Object> cache_type = args.at<Object>(2); |
| 15206 int index = args.smi_at(3); |
| 15207 // Figure out first if a slow check is needed for this object. |
| 15208 bool slow_check_needed = false; |
| 15209 if (cache_type->IsMap()) { |
| 15210 if (object->map() != Map::cast(*cache_type)) { |
| 15211 // Object transitioned. Need slow check. |
| 15212 slow_check_needed = true; |
| 15213 } |
| 15214 } else { |
| 15215 // No slow check needed for proxies. |
| 15216 slow_check_needed = Smi::cast(*cache_type)->value() == 1; |
| 15217 } |
| 15218 return MakePair(array->get(index), |
| 15219 isolate->heap()->ToBoolean(slow_check_needed)); |
| 15220 } |
| 15221 |
| 15222 |
| 15223 // ---------------------------------------------------------------------------- |
| 15224 // Reference implementation for inlined runtime functions. Only used when the |
| 15225 // compiler does not support a certain intrinsic. Don't optimize these, but |
| 15226 // implement the intrinsic in the respective compiler instead. |
| 15227 |
| 15228 // TODO(mstarzinger): These are place-holder stubs for TurboFan and will |
| 15229 // eventually all have a C++ implementation and this macro will be gone. |
| 15230 #define U(name) \ |
| 15231 RUNTIME_FUNCTION(RuntimeReference_##name) { \ |
| 15232 UNIMPLEMENTED(); \ |
| 15233 return NULL; \ |
| 15234 } |
| 15235 |
| 15236 U(IsStringWrapperSafeForDefaultValueOf) |
| 15237 U(GeneratorNext) |
| 15238 U(GeneratorThrow) |
| 15239 U(DebugBreakInOptimizedCode) |
| 15240 |
| 15241 #undef U |
| 15242 |
| 15243 |
| 15244 RUNTIME_FUNCTION(RuntimeReference_IsSmi) { |
| 15245 SealHandleScope shs(isolate); |
| 15246 ASSERT(args.length() == 1); |
| 15247 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15248 return isolate->heap()->ToBoolean(obj->IsSmi()); |
| 15249 } |
| 15250 |
| 15251 |
| 15252 RUNTIME_FUNCTION(RuntimeReference_IsNonNegativeSmi) { |
| 15253 SealHandleScope shs(isolate); |
| 15254 ASSERT(args.length() == 1); |
| 15255 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15256 return isolate->heap()->ToBoolean(obj->IsSmi() && |
| 15257 Smi::cast(obj)->value() >= 0); |
| 15258 } |
| 15259 |
| 15260 |
| 15261 RUNTIME_FUNCTION(RuntimeReference_IsArray) { |
| 15262 SealHandleScope shs(isolate); |
| 15263 ASSERT(args.length() == 1); |
| 15264 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15265 return isolate->heap()->ToBoolean(obj->IsJSArray()); |
| 15266 } |
| 15267 |
| 15268 |
| 15269 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { |
| 15270 SealHandleScope shs(isolate); |
| 15271 ASSERT(args.length() == 1); |
| 15272 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15273 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); |
| 15274 } |
| 15275 |
| 15276 |
| 15277 RUNTIME_FUNCTION(RuntimeReference_IsConstructCall) { |
| 15278 SealHandleScope shs(isolate); |
| 15279 ASSERT(args.length() == 0); |
| 15280 JavaScriptFrameIterator it(isolate); |
| 15281 JavaScriptFrame* frame = it.frame(); |
| 15282 return isolate->heap()->ToBoolean(frame->IsConstructor()); |
| 15283 } |
| 15284 |
| 15285 |
| 15286 RUNTIME_FUNCTION(RuntimeReference_CallFunction) { |
| 15287 SealHandleScope shs(isolate); |
| 15288 return __RT_impl_Runtime_Call(args, isolate); |
| 15289 } |
| 15290 |
| 15291 |
| 15292 RUNTIME_FUNCTION(RuntimeReference_ArgumentsLength) { |
| 15293 SealHandleScope shs(isolate); |
| 15294 ASSERT(args.length() == 0); |
| 15295 JavaScriptFrameIterator it(isolate); |
| 15296 JavaScriptFrame* frame = it.frame(); |
| 15297 return Smi::FromInt(frame->GetArgumentsLength()); |
| 15298 } |
| 15299 |
| 15300 |
| 15301 RUNTIME_FUNCTION(RuntimeReference_Arguments) { |
| 15302 SealHandleScope shs(isolate); |
| 15303 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); |
| 15304 } |
| 15305 |
| 15306 |
| 15307 RUNTIME_FUNCTION(RuntimeReference_ValueOf) { |
| 15308 SealHandleScope shs(isolate); |
| 15309 ASSERT(args.length() == 1); |
| 15310 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15311 if (!obj->IsJSValue()) return obj; |
| 15312 return JSValue::cast(obj)->value(); |
| 15313 } |
| 15314 |
| 15315 |
| 15316 RUNTIME_FUNCTION(RuntimeReference_SetValueOf) { |
| 15317 SealHandleScope shs(isolate); |
| 15318 ASSERT(args.length() == 2); |
| 15319 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15320 CONVERT_ARG_CHECKED(Object, value, 1); |
| 15321 if (!obj->IsJSValue()) return value; |
| 15322 JSValue::cast(obj)->set_value(value); |
| 15323 return value; |
| 15324 } |
| 15325 |
| 15326 |
| 15327 RUNTIME_FUNCTION(RuntimeReference_DateField) { |
| 15328 SealHandleScope shs(isolate); |
| 15329 ASSERT(args.length() == 2); |
| 15330 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15331 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15332 if (!obj->IsJSDate()) { |
| 15333 HandleScope scope(isolate); |
| 15334 return isolate->Throw(*isolate->factory()->NewTypeError( |
| 15335 "not_date_object", HandleVector<Object>(NULL, 0))); |
| 15336 } |
| 15337 JSDate* date = JSDate::cast(obj); |
| 15338 if (index == 0) return date->value(); |
| 15339 return JSDate::GetField(date, Smi::FromInt(index)); |
| 15340 } |
| 15341 |
| 15342 |
| 15343 RUNTIME_FUNCTION(RuntimeReference_StringCharFromCode) { |
| 15344 SealHandleScope shs(isolate); |
| 15345 return __RT_impl_Runtime_CharFromCode(args, isolate); |
| 15346 } |
| 15347 |
| 15348 |
| 15349 RUNTIME_FUNCTION(RuntimeReference_StringCharAt) { |
| 15350 SealHandleScope shs(isolate); |
| 15351 ASSERT(args.length() == 2); |
| 15352 if (!args[0]->IsString()) return Smi::FromInt(0); |
| 15353 if (!args[1]->IsNumber()) return Smi::FromInt(0); |
| 15354 if (std::isinf(args.number_at(1))) return isolate->heap()->empty_string(); |
| 15355 Object* code = __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
| 15356 if (code->IsNaN()) return isolate->heap()->empty_string(); |
| 15357 return __RT_impl_Runtime_CharFromCode(Arguments(1, &code), isolate); |
| 15358 } |
| 15359 |
| 15360 |
| 15361 RUNTIME_FUNCTION(RuntimeReference_OneByteSeqStringSetChar) { |
| 15362 SealHandleScope shs(isolate); |
| 15363 ASSERT(args.length() == 3); |
| 15364 CONVERT_ARG_CHECKED(SeqOneByteString, string, 0); |
| 15365 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15366 CONVERT_SMI_ARG_CHECKED(value, 2); |
| 15367 string->SeqOneByteStringSet(index, value); |
| 15368 return string; |
| 15369 } |
| 15370 |
| 15371 |
| 15372 RUNTIME_FUNCTION(RuntimeReference_TwoByteSeqStringSetChar) { |
| 15373 SealHandleScope shs(isolate); |
| 15374 ASSERT(args.length() == 3); |
| 15375 CONVERT_ARG_CHECKED(SeqTwoByteString, string, 0); |
| 15376 CONVERT_SMI_ARG_CHECKED(index, 1); |
| 15377 CONVERT_SMI_ARG_CHECKED(value, 2); |
| 15378 string->SeqTwoByteStringSet(index, value); |
| 15379 return string; |
| 15380 } |
| 15381 |
| 15382 |
| 15383 RUNTIME_FUNCTION(RuntimeReference_ObjectEquals) { |
| 15384 SealHandleScope shs(isolate); |
| 15385 ASSERT(args.length() == 2); |
| 15386 CONVERT_ARG_CHECKED(Object, obj1, 0); |
| 15387 CONVERT_ARG_CHECKED(Object, obj2, 1); |
| 15388 return isolate->heap()->ToBoolean(obj1 == obj2); |
| 15389 } |
| 15390 |
| 15391 |
| 15392 RUNTIME_FUNCTION(RuntimeReference_IsObject) { |
| 15393 SealHandleScope shs(isolate); |
| 15394 ASSERT(args.length() == 1); |
| 15395 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15396 if (!obj->IsHeapObject()) return isolate->heap()->false_value(); |
| 15397 if (obj->IsNull()) return isolate->heap()->true_value(); |
| 15398 if (obj->IsUndetectableObject()) return isolate->heap()->false_value(); |
| 15399 Map* map = HeapObject::cast(obj)->map(); |
| 15400 bool is_non_callable_spec_object = |
| 15401 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && |
| 15402 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE; |
| 15403 return isolate->heap()->ToBoolean(is_non_callable_spec_object); |
| 15404 } |
| 15405 |
| 15406 |
| 15407 RUNTIME_FUNCTION(RuntimeReference_IsFunction) { |
| 15408 SealHandleScope shs(isolate); |
| 15409 ASSERT(args.length() == 1); |
| 15410 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15411 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
| 15412 } |
| 15413 |
| 15414 |
| 15415 RUNTIME_FUNCTION(RuntimeReference_IsUndetectableObject) { |
| 15416 SealHandleScope shs(isolate); |
| 15417 ASSERT(args.length() == 1); |
| 15418 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15419 return isolate->heap()->ToBoolean(obj->IsUndetectableObject()); |
| 15420 } |
| 15421 |
| 15422 |
| 15423 RUNTIME_FUNCTION(RuntimeReference_IsSpecObject) { |
| 15424 SealHandleScope shs(isolate); |
| 15425 ASSERT(args.length() == 1); |
| 15426 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15427 return isolate->heap()->ToBoolean(obj->IsSpecObject()); |
| 15428 } |
| 15429 |
| 15430 |
| 15431 RUNTIME_FUNCTION(RuntimeReference_MathPow) { |
| 15432 SealHandleScope shs(isolate); |
| 15433 return __RT_impl_Runtime_MathPowSlow(args, isolate); |
| 15434 } |
| 15435 |
| 15436 |
| 15437 RUNTIME_FUNCTION(RuntimeReference_IsMinusZero) { |
| 15438 SealHandleScope shs(isolate); |
| 15439 ASSERT(args.length() == 1); |
| 15440 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15441 if (!obj->IsHeapNumber()) return isolate->heap()->false_value(); |
| 15442 HeapNumber* number = HeapNumber::cast(obj); |
| 15443 return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
| 15444 } |
| 15445 |
| 15446 |
| 15447 RUNTIME_FUNCTION(RuntimeReference_HasCachedArrayIndex) { |
| 15448 SealHandleScope shs(isolate); |
| 15449 ASSERT(args.length() == 1); |
| 15450 return isolate->heap()->false_value(); |
| 15451 } |
| 15452 |
| 15453 |
| 15454 RUNTIME_FUNCTION(RuntimeReference_GetCachedArrayIndex) { |
| 15455 SealHandleScope shs(isolate); |
| 15456 ASSERT(args.length() == 1); |
| 15457 return isolate->heap()->undefined_value(); |
| 15458 } |
| 15459 |
| 15460 |
| 15461 RUNTIME_FUNCTION(RuntimeReference_FastAsciiArrayJoin) { |
| 15462 SealHandleScope shs(isolate); |
| 15463 ASSERT(args.length() == 2); |
| 15464 return isolate->heap()->undefined_value(); |
| 15465 } |
| 15466 |
| 15467 |
| 15468 RUNTIME_FUNCTION(RuntimeReference_ClassOf) { |
| 15469 SealHandleScope shs(isolate); |
| 15470 ASSERT(args.length() == 1); |
| 15471 CONVERT_ARG_CHECKED(Object, obj, 0); |
| 15472 if (!obj->IsJSReceiver()) return isolate->heap()->null_value(); |
| 15473 return JSReceiver::cast(obj)->class_name(); |
| 15474 } |
| 15475 |
| 15476 |
| 15477 RUNTIME_FUNCTION(RuntimeReference_StringCharCodeAt) { |
| 15478 SealHandleScope shs(isolate); |
| 15479 ASSERT(args.length() == 2); |
| 15480 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
| 15481 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
| 15482 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
| 15483 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
| 15484 } |
| 15485 |
| 15486 |
| 15487 RUNTIME_FUNCTION(RuntimeReference_StringAdd) { |
| 15488 SealHandleScope shs(isolate); |
| 15489 return __RT_impl_Runtime_StringAdd(args, isolate); |
| 15490 } |
| 15491 |
| 15492 |
| 15493 RUNTIME_FUNCTION(RuntimeReference_SubString) { |
| 15494 SealHandleScope shs(isolate); |
| 15495 return __RT_impl_Runtime_SubString(args, isolate); |
| 15496 } |
| 15497 |
| 15498 |
| 15499 RUNTIME_FUNCTION(RuntimeReference_StringCompare) { |
| 15500 SealHandleScope shs(isolate); |
| 15501 return __RT_impl_Runtime_StringCompare(args, isolate); |
| 15502 } |
| 15503 |
| 15504 |
| 15505 RUNTIME_FUNCTION(RuntimeReference_RegExpExec) { |
| 15506 SealHandleScope shs(isolate); |
| 15507 return __RT_impl_Runtime_RegExpExecRT(args, isolate); |
| 15508 } |
| 15509 |
| 15510 |
| 15511 RUNTIME_FUNCTION(RuntimeReference_RegExpConstructResult) { |
| 15512 SealHandleScope shs(isolate); |
| 15513 return __RT_impl_Runtime_RegExpConstructResult(args, isolate); |
| 15514 } |
| 15515 |
| 15516 |
| 15517 RUNTIME_FUNCTION(RuntimeReference_GetFromCache) { |
| 15518 HandleScope scope(isolate); |
| 15519 ASSERT(args.length() == 2); |
| 15520 CONVERT_SMI_ARG_CHECKED(id, 0); |
| 15521 args[0] = isolate->native_context()->jsfunction_result_caches()->get(id); |
| 15522 return __RT_impl_Runtime_GetFromCache(args, isolate); |
| 15523 } |
| 15524 |
| 15525 |
| 15526 RUNTIME_FUNCTION(RuntimeReference_NumberToString) { |
| 15527 SealHandleScope shs(isolate); |
| 15528 return __RT_impl_Runtime_NumberToStringRT(args, isolate); |
| 15529 } |
| 15530 |
| 15531 |
| 15532 RUNTIME_FUNCTION(RuntimeReference_DebugIsActive) { |
| 15533 SealHandleScope shs(isolate); |
| 15534 return Smi::FromInt(isolate->debug()->is_active()); |
| 15535 } |
| 15536 |
| 15537 |
15030 // ---------------------------------------------------------------------------- | 15538 // ---------------------------------------------------------------------------- |
15031 // Implementation of Runtime | 15539 // Implementation of Runtime |
15032 | 15540 |
15033 #define F(name, number_of_args, result_size) \ | 15541 #define F(name, number_of_args, result_size) \ |
15034 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 15542 { \ |
15035 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15543 Runtime::k##name, Runtime::RUNTIME, #name, FUNCTION_ADDR(Runtime_##name), \ |
15036 | 15544 number_of_args, result_size \ |
15037 | 15545 } \ |
15038 #define I(name, number_of_args, result_size) \ | 15546 , |
15039 { Runtime::kInline##name, Runtime::INLINE, \ | 15547 |
15040 "_" #name, NULL, number_of_args, result_size }, | 15548 |
15041 | 15549 #define I(name, number_of_args, result_size) \ |
15042 | 15550 { \ |
15043 #define IO(name, number_of_args, result_size) \ | 15551 Runtime::kInline##name, Runtime::INLINE, "_" #name, \ |
15044 { Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, \ | 15552 FUNCTION_ADDR(RuntimeReference_##name), number_of_args, result_size \ |
15045 "_" #name, FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 15553 } \ |
| 15554 , |
| 15555 |
| 15556 |
| 15557 #define IO(name, number_of_args, result_size) \ |
| 15558 { \ |
| 15559 Runtime::kInlineOptimized##name, Runtime::INLINE_OPTIMIZED, "_" #name, \ |
| 15560 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size \ |
| 15561 } \ |
| 15562 , |
15046 | 15563 |
15047 | 15564 |
15048 static const Runtime::Function kIntrinsicFunctions[] = { | 15565 static const Runtime::Function kIntrinsicFunctions[] = { |
15049 RUNTIME_FUNCTION_LIST(F) | 15566 RUNTIME_FUNCTION_LIST(F) |
15050 INLINE_OPTIMIZED_FUNCTION_LIST(F) | 15567 INLINE_OPTIMIZED_FUNCTION_LIST(F) |
15051 INLINE_FUNCTION_LIST(I) | 15568 INLINE_FUNCTION_LIST(I) |
15052 INLINE_OPTIMIZED_FUNCTION_LIST(IO) | 15569 INLINE_OPTIMIZED_FUNCTION_LIST(IO) |
15053 }; | 15570 }; |
15054 | 15571 |
15055 #undef IO | 15572 #undef IO |
(...skipping 24 matching lines...) Expand all Loading... |
15080 int entry = heap->intrinsic_function_names()->FindEntry(name); | 15597 int entry = heap->intrinsic_function_names()->FindEntry(name); |
15081 if (entry != kNotFound) { | 15598 if (entry != kNotFound) { |
15082 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); | 15599 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); |
15083 int function_index = Smi::cast(smi_index)->value(); | 15600 int function_index = Smi::cast(smi_index)->value(); |
15084 return &(kIntrinsicFunctions[function_index]); | 15601 return &(kIntrinsicFunctions[function_index]); |
15085 } | 15602 } |
15086 return NULL; | 15603 return NULL; |
15087 } | 15604 } |
15088 | 15605 |
15089 | 15606 |
| 15607 const Runtime::Function* Runtime::FunctionForEntry(Address entry) { |
| 15608 for (size_t i = 0; i < sizeof(kIntrinsicFunctions); ++i) { |
| 15609 if (entry == kIntrinsicFunctions[i].entry) { |
| 15610 return &(kIntrinsicFunctions[i]); |
| 15611 } |
| 15612 } |
| 15613 return NULL; |
| 15614 } |
| 15615 |
| 15616 |
15090 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15617 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15091 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15618 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15092 } | 15619 } |
15093 | 15620 |
15094 } } // namespace v8::internal | 15621 } } // namespace v8::internal |
OLD | NEW |