OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8947 | 8947 |
8948 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8948 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { |
8949 HandleScope scope(isolate); | 8949 HandleScope scope(isolate); |
8950 ASSERT(args.length() == 1); | 8950 ASSERT(args.length() == 1); |
8951 RUNTIME_ASSERT(!args[0]->IsJSFunction()); | 8951 RUNTIME_ASSERT(!args[0]->IsJSFunction()); |
8952 return *Execution::GetConstructorDelegate(isolate, args.at<Object>(0)); | 8952 return *Execution::GetConstructorDelegate(isolate, args.at<Object>(0)); |
8953 } | 8953 } |
8954 | 8954 |
8955 | 8955 |
8956 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) { | 8956 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) { |
8957 SealHandleScope shs(isolate); | 8957 HandleScope scope(isolate); |
8958 ASSERT(args.length() == 2); | 8958 ASSERT(args.length() == 2); |
8959 | 8959 |
8960 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8960 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8961 CONVERT_ARG_CHECKED(ScopeInfo, scope_info, 1); | 8961 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
8962 Context* result; | 8962 Handle<Context> result = |
8963 MaybeObject* maybe_result = | 8963 isolate->factory()->NewGlobalContext(function, scope_info); |
8964 isolate->heap()->AllocateGlobalContext(function, scope_info); | |
8965 if (!maybe_result->To(&result)) return maybe_result; | |
8966 | 8964 |
8967 ASSERT(function->context() == isolate->context()); | 8965 ASSERT(function->context() == isolate->context()); |
8968 ASSERT(function->context()->global_object() == result->global_object()); | 8966 ASSERT(function->context()->global_object() == result->global_object()); |
8969 result->global_object()->set_global_context(result); | 8967 result->global_object()->set_global_context(*result); |
8970 | 8968 return *result; |
8971 return result; // non-failure | |
8972 } | 8969 } |
8973 | 8970 |
8974 | 8971 |
8975 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewFunctionContext) { | 8972 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewFunctionContext) { |
8976 SealHandleScope shs(isolate); | 8973 HandleScope scope(isolate); |
8977 ASSERT(args.length() == 1); | 8974 ASSERT(args.length() == 1); |
8978 | 8975 |
8979 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8976 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8980 int length = function->shared()->scope_info()->ContextLength(); | 8977 int length = function->shared()->scope_info()->ContextLength(); |
8981 return isolate->heap()->AllocateFunctionContext(length, function); | 8978 Handle<Context> context = |
| 8979 isolate->factory()->NewFunctionContext(length, function); |
| 8980 return *context; |
8982 } | 8981 } |
8983 | 8982 |
8984 | 8983 |
8985 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushWithContext) { | 8984 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushWithContext) { |
8986 SealHandleScope shs(isolate); | 8985 HandleScope scope(isolate); |
8987 ASSERT(args.length() == 2); | 8986 ASSERT(args.length() == 2); |
8988 JSReceiver* extension_object; | 8987 Handle<JSReceiver> extension_object; |
8989 if (args[0]->IsJSReceiver()) { | 8988 if (args[0]->IsJSReceiver()) { |
8990 extension_object = JSReceiver::cast(args[0]); | 8989 extension_object = args.at<JSReceiver>(0); |
8991 } else { | 8990 } else { |
8992 // Convert the object to a proper JavaScript object. | 8991 // Convert the object to a proper JavaScript object. |
8993 MaybeObject* maybe_js_object = args[0]->ToObject(isolate); | 8992 Handle<Object> object = isolate->factory()->ToObject(args.at<Object>(0)); |
8994 if (!maybe_js_object->To(&extension_object)) { | 8993 if (object.is_null()) { |
8995 if (Failure::cast(maybe_js_object)->IsInternalError()) { | 8994 Handle<Object> handle = args.at<Object>(0); |
8996 HandleScope scope(isolate); | 8995 Handle<Object> result = |
8997 Handle<Object> handle = args.at<Object>(0); | 8996 isolate->factory()->NewTypeError("with_expression", |
8998 Handle<Object> result = | 8997 HandleVector(&handle, 1)); |
8999 isolate->factory()->NewTypeError("with_expression", | 8998 return isolate->Throw(*result); |
9000 HandleVector(&handle, 1)); | |
9001 return isolate->Throw(*result); | |
9002 } else { | |
9003 return maybe_js_object; | |
9004 } | |
9005 } | 8999 } |
| 9000 extension_object = Handle<JSReceiver>::cast(object); |
9006 } | 9001 } |
9007 | 9002 |
9008 JSFunction* function; | 9003 Handle<JSFunction> function; |
9009 if (args[1]->IsSmi()) { | 9004 if (args[1]->IsSmi()) { |
9010 // A smi sentinel indicates a context nested inside global code rather | 9005 // A smi sentinel indicates a context nested inside global code rather |
9011 // than some function. There is a canonical empty function that can be | 9006 // than some function. There is a canonical empty function that can be |
9012 // gotten from the native context. | 9007 // gotten from the native context. |
9013 function = isolate->context()->native_context()->closure(); | 9008 function = handle(isolate->context()->native_context()->closure()); |
9014 } else { | 9009 } else { |
9015 function = JSFunction::cast(args[1]); | 9010 function = args.at<JSFunction>(1); |
9016 } | 9011 } |
9017 | 9012 |
9018 Context* context; | 9013 Handle<Context> current(isolate->context()); |
9019 MaybeObject* maybe_context = | 9014 Handle<Context> context = isolate->factory()->NewWithContext( |
9020 isolate->heap()->AllocateWithContext(function, | 9015 function, current, extension_object); |
9021 isolate->context(), | 9016 isolate->set_context(*context); |
9022 extension_object); | 9017 return *context; |
9023 if (!maybe_context->To(&context)) return maybe_context; | |
9024 isolate->set_context(context); | |
9025 return context; | |
9026 } | 9018 } |
9027 | 9019 |
9028 | 9020 |
9029 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushCatchContext) { | 9021 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushCatchContext) { |
9030 SealHandleScope shs(isolate); | 9022 HandleScope scope(isolate); |
9031 ASSERT(args.length() == 3); | 9023 ASSERT(args.length() == 3); |
9032 String* name = String::cast(args[0]); | 9024 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
9033 Object* thrown_object = args[1]; | 9025 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
9034 JSFunction* function; | 9026 Handle<JSFunction> function; |
9035 if (args[2]->IsSmi()) { | 9027 if (args[2]->IsSmi()) { |
9036 // A smi sentinel indicates a context nested inside global code rather | 9028 // A smi sentinel indicates a context nested inside global code rather |
9037 // than some function. There is a canonical empty function that can be | 9029 // than some function. There is a canonical empty function that can be |
9038 // gotten from the native context. | 9030 // gotten from the native context. |
9039 function = isolate->context()->native_context()->closure(); | 9031 function = handle(isolate->context()->native_context()->closure()); |
9040 } else { | 9032 } else { |
9041 function = JSFunction::cast(args[2]); | 9033 function = args.at<JSFunction>(2); |
9042 } | 9034 } |
9043 Context* context; | 9035 Handle<Context> current(isolate->context()); |
9044 MaybeObject* maybe_context = | 9036 Handle<Context> context = isolate->factory()->NewCatchContext( |
9045 isolate->heap()->AllocateCatchContext(function, | 9037 function, current, name, thrown_object); |
9046 isolate->context(), | 9038 isolate->set_context(*context); |
9047 name, | 9039 return *context; |
9048 thrown_object); | |
9049 if (!maybe_context->To(&context)) return maybe_context; | |
9050 isolate->set_context(context); | |
9051 return context; | |
9052 } | 9040 } |
9053 | 9041 |
9054 | 9042 |
9055 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushBlockContext) { | 9043 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushBlockContext) { |
9056 SealHandleScope shs(isolate); | 9044 HandleScope scope(isolate); |
9057 ASSERT(args.length() == 2); | 9045 ASSERT(args.length() == 2); |
9058 ScopeInfo* scope_info = ScopeInfo::cast(args[0]); | 9046 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
9059 JSFunction* function; | 9047 Handle<JSFunction> function; |
9060 if (args[1]->IsSmi()) { | 9048 if (args[1]->IsSmi()) { |
9061 // A smi sentinel indicates a context nested inside global code rather | 9049 // A smi sentinel indicates a context nested inside global code rather |
9062 // than some function. There is a canonical empty function that can be | 9050 // than some function. There is a canonical empty function that can be |
9063 // gotten from the native context. | 9051 // gotten from the native context. |
9064 function = isolate->context()->native_context()->closure(); | 9052 function = handle(isolate->context()->native_context()->closure()); |
9065 } else { | 9053 } else { |
9066 function = JSFunction::cast(args[1]); | 9054 function = args.at<JSFunction>(1); |
9067 } | 9055 } |
9068 Context* context; | 9056 Handle<Context> current(isolate->context()); |
9069 MaybeObject* maybe_context = | 9057 Handle<Context> context = isolate->factory()->NewBlockContext( |
9070 isolate->heap()->AllocateBlockContext(function, | 9058 function, current, scope_info); |
9071 isolate->context(), | 9059 isolate->set_context(*context); |
9072 scope_info); | 9060 return *context; |
9073 if (!maybe_context->To(&context)) return maybe_context; | |
9074 isolate->set_context(context); | |
9075 return context; | |
9076 } | 9061 } |
9077 | 9062 |
9078 | 9063 |
9079 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { | 9064 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { |
9080 SealHandleScope shs(isolate); | 9065 SealHandleScope shs(isolate); |
9081 ASSERT(args.length() == 1); | 9066 ASSERT(args.length() == 1); |
9082 Object* obj = args[0]; | 9067 Object* obj = args[0]; |
9083 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 9068 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
9084 } | 9069 } |
9085 | 9070 |
(...skipping 6136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15222 } | 15207 } |
15223 } | 15208 } |
15224 | 15209 |
15225 | 15210 |
15226 void Runtime::OutOfMemory() { | 15211 void Runtime::OutOfMemory() { |
15227 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15212 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15228 UNREACHABLE(); | 15213 UNREACHABLE(); |
15229 } | 15214 } |
15230 | 15215 |
15231 } } // namespace v8::internal | 15216 } } // namespace v8::internal |
OLD | NEW |