Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Side by Side Diff: src/runtime.cc

Issue 231883007: Return MaybeHandle from Invoke. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 VALUE_INDEX, 1904 VALUE_INDEX,
1905 GETTER_INDEX, 1905 GETTER_INDEX,
1906 SETTER_INDEX, 1906 SETTER_INDEX,
1907 WRITABLE_INDEX, 1907 WRITABLE_INDEX,
1908 ENUMERABLE_INDEX, 1908 ENUMERABLE_INDEX,
1909 CONFIGURABLE_INDEX, 1909 CONFIGURABLE_INDEX,
1910 DESCRIPTOR_SIZE 1910 DESCRIPTOR_SIZE
1911 }; 1911 };
1912 1912
1913 1913
1914 MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty( 1914 MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate,
1915 Isolate* isolate, 1915 Handle<JSObject> obj,
1916 Handle<JSObject> obj, 1916 Handle<Name> name) {
1917 Handle<Name> name) {
1918 Heap* heap = isolate->heap(); 1917 Heap* heap = isolate->heap();
1919 Factory* factory = isolate->factory(); 1918 Factory* factory = isolate->factory();
1920 // Due to some WebKit tests, we want to make sure that we do not log 1919 // Due to some WebKit tests, we want to make sure that we do not log
1921 // more than one access failure here. 1920 // more than one access failure here.
1922 AccessCheckResult access_check_result = 1921 AccessCheckResult access_check_result =
1923 CheckPropertyAccess(obj, name, v8::ACCESS_HAS); 1922 CheckPropertyAccess(obj, name, v8::ACCESS_HAS);
1924 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1923 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
1925 switch (access_check_result) { 1924 switch (access_check_result) {
1926 case ACCESS_FORBIDDEN: return factory->false_value(); 1925 case ACCESS_FORBIDDEN: return factory->false_value();
1927 case ACCESS_ALLOWED: break; 1926 case ACCESS_ALLOWED: break;
1928 case ACCESS_ABSENT: return factory->undefined_value(); 1927 case ACCESS_ABSENT: return factory->undefined_value();
1929 } 1928 }
1930 1929
1931 PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name); 1930 PropertyAttributes attrs = JSReceiver::GetLocalPropertyAttribute(obj, name);
1932 if (attrs == ABSENT) { 1931 if (attrs == ABSENT) {
1933 RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object); 1932 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
1934 return factory->undefined_value(); 1933 return factory->undefined_value();
1935 } 1934 }
1936 ASSERT(!isolate->has_scheduled_exception()); 1935 ASSERT(!isolate->has_scheduled_exception());
1937 Handle<AccessorPair> accessors; 1936 Handle<AccessorPair> accessors;
1938 bool has_accessors = 1937 bool has_accessors =
1939 JSObject::GetLocalPropertyAccessorPair(obj, name).ToHandle(&accessors); 1938 JSObject::GetLocalPropertyAccessorPair(obj, name).ToHandle(&accessors);
1940 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE); 1939 Handle<FixedArray> elms = isolate->factory()->NewFixedArray(DESCRIPTOR_SIZE);
1941 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0)); 1940 elms->set(ENUMERABLE_INDEX, heap->ToBoolean((attrs & DONT_ENUM) == 0));
1942 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0)); 1941 elms->set(CONFIGURABLE_INDEX, heap->ToBoolean((attrs & DONT_DELETE) == 0));
1943 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors)); 1942 elms->set(IS_ACCESSOR_INDEX, heap->ToBoolean(has_accessors));
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 } 2046 }
2048 2047
2049 2048
2050 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { 2049 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) {
2051 SealHandleScope shs(isolate); 2050 SealHandleScope shs(isolate);
2052 ASSERT(args.length() == 2); 2051 ASSERT(args.length() == 2);
2053 CONVERT_ARG_CHECKED(HeapObject, templ, 0); 2052 CONVERT_ARG_CHECKED(HeapObject, templ, 0);
2054 CONVERT_SMI_ARG_CHECKED(index, 1) 2053 CONVERT_SMI_ARG_CHECKED(index, 1)
2055 int offset = index * kPointerSize + HeapObject::kHeaderSize; 2054 int offset = index * kPointerSize + HeapObject::kHeaderSize;
2056 InstanceType type = templ->map()->instance_type(); 2055 InstanceType type = templ->map()->instance_type();
2057 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || 2056 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE ||
2058 type == OBJECT_TEMPLATE_INFO_TYPE); 2057 type == OBJECT_TEMPLATE_INFO_TYPE);
2059 RUNTIME_ASSERT(offset > 0); 2058 RUNTIME_ASSERT(offset > 0);
2060 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { 2059 if (type == FUNCTION_TEMPLATE_INFO_TYPE) {
2061 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); 2060 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize);
2062 } else { 2061 } else {
2063 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); 2062 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize);
2064 } 2063 }
2065 return *HeapObject::RawField(templ, offset); 2064 return *HeapObject::RawField(templ, offset);
2066 } 2065 }
2067 2066
2068 2067
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 return *holder; 2732 return *holder;
2734 } 2733 }
2735 2734
2736 2735
2737 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsSloppyModeFunction) { 2736 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsSloppyModeFunction) {
2738 SealHandleScope shs(isolate); 2737 SealHandleScope shs(isolate);
2739 ASSERT(args.length() == 1); 2738 ASSERT(args.length() == 1);
2740 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2739 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2741 if (!callable->IsJSFunction()) { 2740 if (!callable->IsJSFunction()) {
2742 HandleScope scope(isolate); 2741 HandleScope scope(isolate);
2743 bool threw = false; 2742 Handle<Object> delegate;
2744 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2743 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2745 isolate, Handle<JSReceiver>(callable), &threw); 2744 isolate, delegate,
2746 if (threw) return Failure::Exception(); 2745 Execution::TryGetFunctionDelegate(
2746 isolate, Handle<JSReceiver>(callable)));
2747 callable = JSFunction::cast(*delegate); 2747 callable = JSFunction::cast(*delegate);
2748 } 2748 }
2749 JSFunction* function = JSFunction::cast(callable); 2749 JSFunction* function = JSFunction::cast(callable);
2750 SharedFunctionInfo* shared = function->shared(); 2750 SharedFunctionInfo* shared = function->shared();
2751 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); 2751 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY);
2752 } 2752 }
2753 2753
2754 2754
2755 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 2755 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
2756 SealHandleScope shs(isolate); 2756 SealHandleScope shs(isolate);
2757 ASSERT(args.length() == 1); 2757 ASSERT(args.length() == 1);
2758 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2758 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2759 2759
2760 if (!callable->IsJSFunction()) { 2760 if (!callable->IsJSFunction()) {
2761 HandleScope scope(isolate); 2761 HandleScope scope(isolate);
2762 bool threw = false; 2762 Handle<Object> delegate;
2763 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2763 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2764 isolate, Handle<JSReceiver>(callable), &threw); 2764 isolate, delegate,
2765 if (threw) return Failure::Exception(); 2765 Execution::TryGetFunctionDelegate(
2766 isolate, Handle<JSReceiver>(callable)));
2766 callable = JSFunction::cast(*delegate); 2767 callable = JSFunction::cast(*delegate);
2767 } 2768 }
2768 JSFunction* function = JSFunction::cast(callable); 2769 JSFunction* function = JSFunction::cast(callable);
2769 2770
2770 SharedFunctionInfo* shared = function->shared(); 2771 SharedFunctionInfo* shared = function->shared();
2771 if (shared->native() || shared->strict_mode() == STRICT) { 2772 if (shared->native() || shared->strict_mode() == STRICT) {
2772 return isolate->heap()->undefined_value(); 2773 return isolate->heap()->undefined_value();
2773 } 2774 }
2774 // Returns undefined for strict or native functions, or 2775 // Returns undefined for strict or native functions, or
2775 // the associated global receiver for "normal" functions. 2776 // the associated global receiver for "normal" functions.
(...skipping 14 matching lines...) Expand all
2790 2791
2791 // Get the RegExp function from the context in the literals array. 2792 // Get the RegExp function from the context in the literals array.
2792 // This is the RegExp function from the context in which the 2793 // This is the RegExp function from the context in which the
2793 // function was created. We do not use the RegExp function from the 2794 // function was created. We do not use the RegExp function from the
2794 // current native context because this might be the RegExp function 2795 // current native context because this might be the RegExp function
2795 // from another context which we should not have access to. 2796 // from another context which we should not have access to.
2796 Handle<JSFunction> constructor = 2797 Handle<JSFunction> constructor =
2797 Handle<JSFunction>( 2798 Handle<JSFunction>(
2798 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); 2799 JSFunction::NativeContextFromLiterals(*literals)->regexp_function());
2799 // Compute the regular expression literal. 2800 // Compute the regular expression literal.
2800 bool has_pending_exception; 2801 Handle<Object> regexp;
2801 Handle<Object> regexp = 2802 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
2802 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags, 2803 isolate, regexp,
2803 &has_pending_exception); 2804 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags));
2804 if (has_pending_exception) {
2805 ASSERT(isolate->has_pending_exception());
2806 return Failure::Exception();
2807 }
2808 literals->set(index, *regexp); 2805 literals->set(index, *regexp);
2809 return *regexp; 2806 return *regexp;
2810 } 2807 }
2811 2808
2812 2809
2813 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { 2810 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) {
2814 SealHandleScope shs(isolate); 2811 SealHandleScope shs(isolate);
2815 ASSERT(args.length() == 1); 2812 ASSERT(args.length() == 1);
2816 2813
2817 CONVERT_ARG_CHECKED(JSFunction, f, 0); 2814 CONVERT_ARG_CHECKED(JSFunction, f, 0);
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
4908 Handle<Object> result; 4905 Handle<Object> result;
4909 if (object->IsString() || object->IsNumber() || object->IsBoolean()) { 4906 if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
4910 Handle<Object> proto(object->GetPrototype(isolate), isolate); 4907 Handle<Object> proto(object->GetPrototype(isolate), isolate);
4911 return Object::GetElement(isolate, proto, index); 4908 return Object::GetElement(isolate, proto, index);
4912 } else { 4909 } else {
4913 return Object::GetElement(isolate, object, index); 4910 return Object::GetElement(isolate, object, index);
4914 } 4911 }
4915 } 4912 }
4916 4913
4917 4914
4918 static Handle<Name> ToName(Isolate* isolate, Handle<Object> key) { 4915 MUST_USE_RESULT
4916 static MaybeHandle<Name> ToName(Isolate* isolate, Handle<Object> key) {
4919 if (key->IsName()) { 4917 if (key->IsName()) {
4920 return Handle<Name>::cast(key); 4918 return Handle<Name>::cast(key);
4921 } else { 4919 } else {
4922 bool has_pending_exception = false; 4920 Handle<Object> converted;
4923 Handle<Object> converted = 4921 ASSIGN_RETURN_ON_EXCEPTION(
4924 Execution::ToString(isolate, key, &has_pending_exception); 4922 isolate, converted, Execution::ToString(isolate, key), Name);
4925 if (has_pending_exception) return Handle<Name>();
4926 return Handle<Name>::cast(converted); 4923 return Handle<Name>::cast(converted);
4927 } 4924 }
4928 } 4925 }
4929 4926
4930 4927
4931 MaybeHandle<Object> Runtime::HasObjectProperty(Isolate* isolate, 4928 MaybeHandle<Object> Runtime::HasObjectProperty(Isolate* isolate,
4932 Handle<JSReceiver> object, 4929 Handle<JSReceiver> object,
4933 Handle<Object> key) { 4930 Handle<Object> key) {
4934 // Check if the given key is an array index. 4931 // Check if the given key is an array index.
4935 uint32_t index; 4932 uint32_t index;
4936 if (key->ToArrayIndex(&index)) { 4933 if (key->ToArrayIndex(&index)) {
4937 return isolate->factory()->ToBoolean(JSReceiver::HasElement(object, index)); 4934 return isolate->factory()->ToBoolean(JSReceiver::HasElement(object, index));
4938 } 4935 }
4939 4936
4940 // Convert the key to a name - possibly by calling back into JavaScript. 4937 // Convert the key to a name - possibly by calling back into JavaScript.
4941 Handle<Name> name = ToName(isolate, key); 4938 Handle<Name> name;
4942 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>()); 4939 ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
4943 4940
4944 return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name)); 4941 return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name));
4945 } 4942 }
4946 4943
4947 4944
4948 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, 4945 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
4949 Handle<Object> object, 4946 Handle<Object> object,
4950 Handle<Object> key) { 4947 Handle<Object> key) {
4951 if (object->IsUndefined() || object->IsNull()) { 4948 if (object->IsUndefined() || object->IsNull()) {
4952 Handle<Object> args[2] = { key, object }; 4949 Handle<Object> args[2] = { key, object };
4953 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load", 4950 return isolate->Throw<Object>(
4954 HandleVector(args, 2))); 4951 isolate->factory()->NewTypeError("non_object_property_load",
4955 return Handle<Object>(); 4952 HandleVector(args, 2)));
4956 } 4953 }
4957 4954
4958 // Check if the given key is an array index. 4955 // Check if the given key is an array index.
4959 uint32_t index; 4956 uint32_t index;
4960 if (key->ToArrayIndex(&index)) { 4957 if (key->ToArrayIndex(&index)) {
4961 return GetElementOrCharAt(isolate, object, index); 4958 return GetElementOrCharAt(isolate, object, index);
4962 } 4959 }
4963 4960
4964 // Convert the key to a name - possibly by calling back into JavaScript. 4961 // Convert the key to a name - possibly by calling back into JavaScript.
4965 Handle<Name> name = ToName(isolate, key); 4962 Handle<Name> name;
4966 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, Handle<Object>()); 4963 ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object);
4967 4964
4968 // Check if the name is trivially convertible to an index and get 4965 // Check if the name is trivially convertible to an index and get
4969 // the element if so. 4966 // the element if so.
4970 if (name->AsArrayIndex(&index)) { 4967 if (name->AsArrayIndex(&index)) {
4971 return GetElementOrCharAt(isolate, object, index); 4968 return GetElementOrCharAt(isolate, object, index);
4972 } else { 4969 } else {
4973 return Object::GetProperty(object, name); 4970 return Object::GetProperty(object, name);
4974 } 4971 }
4975 } 4972 }
4976 4973
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
5248 if (object->IsUndefined() || object->IsNull()) { 5245 if (object->IsUndefined() || object->IsNull()) {
5249 Handle<Object> args[2] = { key, object }; 5246 Handle<Object> args[2] = { key, object };
5250 Handle<Object> error = 5247 Handle<Object> error =
5251 isolate->factory()->NewTypeError("non_object_property_store", 5248 isolate->factory()->NewTypeError("non_object_property_store",
5252 HandleVector(args, 2)); 5249 HandleVector(args, 2));
5253 isolate->Throw(*error); 5250 isolate->Throw(*error);
5254 return Handle<Object>(); 5251 return Handle<Object>();
5255 } 5252 }
5256 5253
5257 if (object->IsJSProxy()) { 5254 if (object->IsJSProxy()) {
5258 bool has_pending_exception = false; 5255 Handle<Object> name_object;
5259 Handle<Object> name_object = key->IsSymbol() 5256 if (key->IsSymbol()) {
5260 ? key : Execution::ToString(isolate, key, &has_pending_exception); 5257 name_object = key;
5261 if (has_pending_exception) return MaybeHandle<Object>(); // exception 5258 } else {
5259 ASSIGN_RETURN_ON_EXCEPTION(
5260 isolate, name_object, Execution::ToString(isolate, key), Object);
5261 }
5262 Handle<Name> name = Handle<Name>::cast(name_object); 5262 Handle<Name> name = Handle<Name>::cast(name_object);
5263 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value, 5263 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
5264 attr, 5264 attr,
5265 strict_mode); 5265 strict_mode);
5266 } 5266 }
5267 5267
5268 // If the object isn't a JavaScript object, we ignore the store. 5268 // If the object isn't a JavaScript object, we ignore the store.
5269 if (!object->IsJSObject()) return value; 5269 if (!object->IsJSObject()) return value;
5270 5270
5271 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5271 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
5272 5272
5273 // Check if the given key is an array index. 5273 // Check if the given key is an array index.
5274 uint32_t index; 5274 uint32_t index;
5275 if (key->ToArrayIndex(&index)) { 5275 if (key->ToArrayIndex(&index)) {
5276 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters 5276 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
5277 // of a string using [] notation. We need to support this too in 5277 // of a string using [] notation. We need to support this too in
5278 // JavaScript. 5278 // JavaScript.
5279 // In the case of a String object we just need to redirect the assignment to 5279 // In the case of a String object we just need to redirect the assignment to
5280 // the underlying string if the index is in range. Since the underlying 5280 // the underlying string if the index is in range. Since the underlying
5281 // string does nothing with the assignment then we can ignore such 5281 // string does nothing with the assignment then we can ignore such
5282 // assignments. 5282 // assignments.
5283 if (js_object->IsStringObjectWithCharacterAt(index)) { 5283 if (js_object->IsStringObjectWithCharacterAt(index)) {
5284 return value; 5284 return value;
5285 } 5285 }
5286 5286
5287 JSObject::ValidateElements(js_object); 5287 JSObject::ValidateElements(js_object);
5288 if (js_object->HasExternalArrayElements() || 5288 if (js_object->HasExternalArrayElements() ||
5289 js_object->HasFixedTypedArrayElements()) { 5289 js_object->HasFixedTypedArrayElements()) {
5290 if (!value->IsNumber() && !value->IsUndefined()) { 5290 if (!value->IsNumber() && !value->IsUndefined()) {
5291 bool has_exception; 5291 ASSIGN_RETURN_ON_EXCEPTION(
5292 Handle<Object> number = 5292 isolate, value, Execution::ToNumber(isolate, value), Object);
5293 Execution::ToNumber(isolate, value, &has_exception);
5294 if (has_exception) return MaybeHandle<Object>(); // exception
5295 value = number;
5296 } 5293 }
5297 } 5294 }
5298 5295
5299 MaybeHandle<Object> result = JSObject::SetElement( 5296 MaybeHandle<Object> result = JSObject::SetElement(
5300 js_object, index, value, attr, strict_mode, true, set_mode); 5297 js_object, index, value, attr, strict_mode, true, set_mode);
5301 JSObject::ValidateElements(js_object); 5298 JSObject::ValidateElements(js_object);
5302 5299
5303 return result.is_null() ? result : value; 5300 return result.is_null() ? result : value;
5304 } 5301 }
5305 5302
5306 if (key->IsName()) { 5303 if (key->IsName()) {
5307 Handle<Name> name = Handle<Name>::cast(key); 5304 Handle<Name> name = Handle<Name>::cast(key);
5308 if (name->AsArrayIndex(&index)) { 5305 if (name->AsArrayIndex(&index)) {
5309 if (js_object->HasExternalArrayElements()) { 5306 if (js_object->HasExternalArrayElements()) {
5310 if (!value->IsNumber() && !value->IsUndefined()) { 5307 if (!value->IsNumber() && !value->IsUndefined()) {
5311 bool has_exception; 5308 ASSIGN_RETURN_ON_EXCEPTION(
5312 Handle<Object> number = 5309 isolate, value, Execution::ToNumber(isolate, value), Object);
5313 Execution::ToNumber(isolate, value, &has_exception);
5314 if (has_exception) return MaybeHandle<Object>(); // exception
5315 value = number;
5316 } 5310 }
5317 } 5311 }
5318 return JSObject::SetElement(js_object, index, value, attr, 5312 return JSObject::SetElement(js_object, index, value, attr,
5319 strict_mode, true, set_mode); 5313 strict_mode, true, set_mode);
5320 } else { 5314 } else {
5321 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5315 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5322 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5316 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5323 } 5317 }
5324 } 5318 }
5325 5319
5326 // Call-back into JavaScript to convert the key to a string. 5320 // Call-back into JavaScript to convert the key to a string.
5327 bool has_pending_exception = false; 5321 Handle<Object> converted;
5328 Handle<Object> converted = 5322 ASSIGN_RETURN_ON_EXCEPTION(
5329 Execution::ToString(isolate, key, &has_pending_exception); 5323 isolate, converted, Execution::ToString(isolate, key), Object);
5330 if (has_pending_exception) return MaybeHandle<Object>(); // exception
5331 Handle<String> name = Handle<String>::cast(converted); 5324 Handle<String> name = Handle<String>::cast(converted);
5332 5325
5333 if (name->AsArrayIndex(&index)) { 5326 if (name->AsArrayIndex(&index)) {
5334 return JSObject::SetElement(js_object, index, value, attr, 5327 return JSObject::SetElement(js_object, index, value, attr,
5335 strict_mode, true, set_mode); 5328 strict_mode, true, set_mode);
5336 } else { 5329 } else {
5337 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5330 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5338 } 5331 }
5339 } 5332 }
5340 5333
(...skipping 27 matching lines...) Expand all
5368 return JSObject::SetElement(js_object, index, value, attr, 5361 return JSObject::SetElement(js_object, index, value, attr,
5369 SLOPPY, false, DEFINE_PROPERTY); 5362 SLOPPY, false, DEFINE_PROPERTY);
5370 } else { 5363 } else {
5371 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5364 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5372 return JSObject::SetLocalPropertyIgnoreAttributes( 5365 return JSObject::SetLocalPropertyIgnoreAttributes(
5373 js_object, name, value, attr); 5366 js_object, name, value, attr);
5374 } 5367 }
5375 } 5368 }
5376 5369
5377 // Call-back into JavaScript to convert the key to a string. 5370 // Call-back into JavaScript to convert the key to a string.
5378 bool has_pending_exception = false; 5371 Handle<Object> converted;
5379 Handle<Object> converted = 5372 ASSIGN_RETURN_ON_EXCEPTION(
5380 Execution::ToString(isolate, key, &has_pending_exception); 5373 isolate, converted, Execution::ToString(isolate, key), Object);
5381 if (has_pending_exception) return MaybeHandle<Object>(); // exception
5382 Handle<String> name = Handle<String>::cast(converted); 5374 Handle<String> name = Handle<String>::cast(converted);
5383 5375
5384 if (name->AsArrayIndex(&index)) { 5376 if (name->AsArrayIndex(&index)) {
5385 return JSObject::SetElement(js_object, index, value, attr, 5377 return JSObject::SetElement(js_object, index, value, attr,
5386 SLOPPY, false, DEFINE_PROPERTY); 5378 SLOPPY, false, DEFINE_PROPERTY);
5387 } else { 5379 } else {
5388 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value, 5380 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
5389 attr); 5381 attr);
5390 } 5382 }
5391 } 5383 }
(...skipping 17 matching lines...) Expand all
5409 } 5401 }
5410 5402
5411 return JSReceiver::DeleteElement(receiver, index, mode); 5403 return JSReceiver::DeleteElement(receiver, index, mode);
5412 } 5404 }
5413 5405
5414 Handle<Name> name; 5406 Handle<Name> name;
5415 if (key->IsName()) { 5407 if (key->IsName()) {
5416 name = Handle<Name>::cast(key); 5408 name = Handle<Name>::cast(key);
5417 } else { 5409 } else {
5418 // Call-back into JavaScript to convert the key to a string. 5410 // Call-back into JavaScript to convert the key to a string.
5419 bool has_pending_exception = false; 5411 Handle<Object> converted;
5420 Handle<Object> converted = Execution::ToString( 5412 ASSIGN_RETURN_ON_EXCEPTION(
5421 isolate, key, &has_pending_exception); 5413 isolate, converted, Execution::ToString(isolate, key), Object);
5422 if (has_pending_exception) return MaybeHandle<Object>();
5423 name = Handle<String>::cast(converted); 5414 name = Handle<String>::cast(converted);
5424 } 5415 }
5425 5416
5426 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5417 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5427 return JSReceiver::DeleteProperty(receiver, name, mode); 5418 return JSReceiver::DeleteProperty(receiver, name, mode);
5428 } 5419 }
5429 5420
5430 5421
5431 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) { 5422 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) {
5432 HandleScope scope(isolate); 5423 HandleScope scope(isolate);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
5751 ASSERT(!isolate->has_scheduled_exception()); 5742 ASSERT(!isolate->has_scheduled_exception());
5752 return isolate->heap()->true_value(); 5743 return isolate->heap()->true_value();
5753 } 5744 }
5754 5745
5755 5746
5756 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 5747 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
5757 HandleScope scope(isolate); 5748 HandleScope scope(isolate);
5758 ASSERT(args.length() == 1); 5749 ASSERT(args.length() == 1);
5759 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); 5750 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
5760 Handle<JSArray> result; 5751 Handle<JSArray> result;
5761 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, GetKeysFor(object)); 5752
5762 return *result; 5753 isolate->counters()->for_in()->Increment();
5754 Handle<FixedArray> elements;
5755 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5756 isolate, elements, GetKeysInFixedArrayFor(object, INCLUDE_PROTOS));
5757 return *isolate->factory()->NewJSArrayWithElements(elements);
5763 } 5758 }
5764 5759
5765 5760
5766 // Returns either a FixedArray as Runtime_GetPropertyNames, 5761 // Returns either a FixedArray as Runtime_GetPropertyNames,
5767 // or, if the given object has an enum cache that contains 5762 // or, if the given object has an enum cache that contains
5768 // all enumerable properties of the object and its prototypes 5763 // all enumerable properties of the object and its prototypes
5769 // have none, the map of the object. This is used to speed up 5764 // have none, the map of the object. This is used to speed up
5770 // the check for deletions during a for-in. 5765 // the check for deletions during a for-in.
5771 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { 5766 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) {
5772 SealHandleScope shs(isolate); 5767 SealHandleScope shs(isolate);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
6057 HandleScope scope(isolate); 6052 HandleScope scope(isolate);
6058 if (args[0]->IsSymbol()) { 6053 if (args[0]->IsSymbol()) {
6059 // Lookup in the initial Object.prototype object. 6054 // Lookup in the initial Object.prototype object.
6060 Handle<Object> result = Object::GetProperty( 6055 Handle<Object> result = Object::GetProperty(
6061 isolate->initial_object_prototype(), args.at<Symbol>(0)); 6056 isolate->initial_object_prototype(), args.at<Symbol>(0));
6062 RETURN_IF_EMPTY_HANDLE(isolate, result); 6057 RETURN_IF_EMPTY_HANDLE(isolate, result);
6063 return *result; 6058 return *result;
6064 } 6059 }
6065 6060
6066 // Convert the key to a string. 6061 // Convert the key to a string.
6067 bool exception = false; 6062 Handle<Object> converted;
6068 Handle<Object> converted = 6063 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
6069 Execution::ToString(isolate, args.at<Object>(0), &exception); 6064 isolate, converted, Execution::ToString(isolate, args.at<Object>(0)));
6070 if (exception) return Failure::Exception();
6071 Handle<String> key = Handle<String>::cast(converted); 6065 Handle<String> key = Handle<String>::cast(converted);
6072 6066
6073 // Try to convert the string key into an array index. 6067 // Try to convert the string key into an array index.
6074 if (key->AsArrayIndex(&index)) { 6068 if (key->AsArrayIndex(&index)) {
6075 if (index < n) { 6069 if (index < n) {
6076 return frame->GetParameter(index); 6070 return frame->GetParameter(index);
6077 } else { 6071 } else {
6078 Handle<Object> initial_prototype(isolate->initial_object_prototype()); 6072 Handle<Object> initial_prototype(isolate->initial_object_prototype());
6079 Handle<Object> result; 6073 Handle<Object> result;
6080 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 6074 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after
8273 8267
8274 int total_argc = 0; 8268 int total_argc = 0;
8275 SmartArrayPointer<Handle<Object> > param_data = 8269 SmartArrayPointer<Handle<Object> > param_data =
8276 GetCallerArguments(isolate, bound_argc, &total_argc); 8270 GetCallerArguments(isolate, bound_argc, &total_argc);
8277 for (int i = 0; i < bound_argc; i++) { 8271 for (int i = 0; i < bound_argc; i++) {
8278 param_data[i] = Handle<Object>(bound_args->get( 8272 param_data[i] = Handle<Object>(bound_args->get(
8279 JSFunction::kBoundArgumentsStartIndex + i), isolate); 8273 JSFunction::kBoundArgumentsStartIndex + i), isolate);
8280 } 8274 }
8281 8275
8282 if (!bound_function->IsJSFunction()) { 8276 if (!bound_function->IsJSFunction()) {
8283 bool exception_thrown; 8277 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8284 bound_function = Execution::TryGetConstructorDelegate(isolate, 8278 isolate, bound_function,
8285 bound_function, 8279 Execution::TryGetConstructorDelegate(isolate, bound_function));
8286 &exception_thrown);
8287 if (exception_thrown) return Failure::Exception();
8288 } 8280 }
8289 ASSERT(bound_function->IsJSFunction()); 8281 ASSERT(bound_function->IsJSFunction());
8290 8282
8291 bool exception = false; 8283 Handle<Object> result;
8292 Handle<Object> result = 8284 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8285 isolate, result,
8293 Execution::New(Handle<JSFunction>::cast(bound_function), 8286 Execution::New(Handle<JSFunction>::cast(bound_function),
8294 total_argc, param_data.get(), &exception); 8287 total_argc, param_data.get()));
8295 if (exception) {
8296 return Failure::Exception();
8297 }
8298 ASSERT(!result.is_null());
8299 return *result; 8288 return *result;
8300 } 8289 }
8301 8290
8302 8291
8303 static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate, 8292 static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate,
8304 Handle<Object> constructor, 8293 Handle<Object> constructor,
8305 Handle<AllocationSite> site) { 8294 Handle<AllocationSite> site) {
8306 // If the constructor isn't a proper function we throw a type error. 8295 // If the constructor isn't a proper function we throw a type error.
8307 if (!constructor->IsJSFunction()) { 8296 if (!constructor->IsJSFunction()) {
8308 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); 8297 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1);
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
8898 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8887 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
8899 } 8888 }
8900 8889
8901 for (int i = 0; i < argc; ++i) { 8890 for (int i = 0; i < argc; ++i) {
8902 MaybeObject* maybe = args[1 + i]; 8891 MaybeObject* maybe = args[1 + i];
8903 Object* object; 8892 Object* object;
8904 if (!maybe->To<Object>(&object)) return maybe; 8893 if (!maybe->To<Object>(&object)) return maybe;
8905 argv[i] = Handle<Object>(object, isolate); 8894 argv[i] = Handle<Object>(object, isolate);
8906 } 8895 }
8907 8896
8908 bool threw;
8909 Handle<JSReceiver> hfun(fun); 8897 Handle<JSReceiver> hfun(fun);
8910 Handle<Object> hreceiver(receiver, isolate); 8898 Handle<Object> hreceiver(receiver, isolate);
8911 Handle<Object> result = Execution::Call( 8899 Handle<Object> result;
8912 isolate, hfun, hreceiver, argc, argv, &threw, true); 8900 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8913 8901 isolate, result,
8914 if (threw) return Failure::Exception(); 8902 Execution::Call(isolate, hfun, hreceiver, argc, argv, true));
8915 return *result; 8903 return *result;
8916 } 8904 }
8917 8905
8918 8906
8919 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { 8907 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) {
8920 HandleScope scope(isolate); 8908 HandleScope scope(isolate);
8921 ASSERT(args.length() == 5); 8909 ASSERT(args.length() == 5);
8922 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); 8910 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0);
8923 Handle<Object> receiver = args.at<Object>(1); 8911 Handle<Object> receiver = args.at<Object>(1);
8924 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); 8912 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2);
(...skipping 12 matching lines...) Expand all
8937 if (argv == NULL) return isolate->StackOverflow(); 8925 if (argv == NULL) return isolate->StackOverflow();
8938 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv); 8926 argv_large_buffer = SmartArrayPointer<Handle<Object> >(argv);
8939 } 8927 }
8940 8928
8941 for (int i = 0; i < argc; ++i) { 8929 for (int i = 0; i < argc; ++i) {
8942 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 8930 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8943 isolate, argv[i], 8931 isolate, argv[i],
8944 Object::GetElement(isolate, arguments, offset + i)); 8932 Object::GetElement(isolate, arguments, offset + i));
8945 } 8933 }
8946 8934
8947 bool threw; 8935 Handle<Object> result;
8948 Handle<Object> result = Execution::Call( 8936 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
8949 isolate, fun, receiver, argc, argv, &threw, true); 8937 isolate, result,
8950 8938 Execution::Call(isolate, fun, receiver, argc, argv, true));
8951 if (threw) return Failure::Exception();
8952 return *result; 8939 return *result;
8953 } 8940 }
8954 8941
8955 8942
8956 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { 8943 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) {
8957 HandleScope scope(isolate); 8944 HandleScope scope(isolate);
8958 ASSERT(args.length() == 1); 8945 ASSERT(args.length() == 1);
8959 RUNTIME_ASSERT(!args[0]->IsJSFunction()); 8946 RUNTIME_ASSERT(!args[0]->IsJSFunction());
8960 return *Execution::GetFunctionDelegate(isolate, args.at<Object>(0)); 8947 return *Execution::GetFunctionDelegate(isolate, args.at<Object>(0));
8961 } 8948 }
(...skipping 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after
12883 } 12870 }
12884 12871
12885 Handle<JSFunction> eval_fun = 12872 Handle<JSFunction> eval_fun =
12886 Compiler::GetFunctionFromEval(source, 12873 Compiler::GetFunctionFromEval(source,
12887 context, 12874 context,
12888 SLOPPY, 12875 SLOPPY,
12889 NO_PARSE_RESTRICTION, 12876 NO_PARSE_RESTRICTION,
12890 RelocInfo::kNoPosition); 12877 RelocInfo::kNoPosition);
12891 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun); 12878 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
12892 12879
12893 bool pending_exception; 12880 Handle<Object> result;
12894 Handle<Object> result = Execution::Call( 12881 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
12895 isolate, eval_fun, receiver, 0, NULL, &pending_exception); 12882 isolate, result,
12896 12883 Execution::Call(isolate, eval_fun, receiver, 0, NULL));
12897 if (pending_exception) return Failure::Exception();
12898 12884
12899 // Skip the global proxy as it has no properties and always delegates to the 12885 // Skip the global proxy as it has no properties and always delegates to the
12900 // real global object. 12886 // real global object.
12901 if (result->IsJSGlobalProxy()) { 12887 if (result->IsJSGlobalProxy()) {
12902 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate))); 12888 result = Handle<JSObject>(JSObject::cast(result->GetPrototype(isolate)));
12903 } 12889 }
12904 12890
12905 // Clear the oneshot breakpoints so that the debugger does not step further. 12891 // Clear the oneshot breakpoints so that the debugger does not step further.
12906 isolate->debug()->ClearStepping(); 12892 isolate->debug()->ClearStepping();
12907 return *result; 12893 return *result;
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
13647 13633
13648 // Calls specified function with or without entering the debugger. 13634 // Calls specified function with or without entering the debugger.
13649 // This is used in unit tests to run code as if debugger is entered or simply 13635 // This is used in unit tests to run code as if debugger is entered or simply
13650 // to have a stack with C++ frame in the middle. 13636 // to have a stack with C++ frame in the middle.
13651 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { 13637 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) {
13652 HandleScope scope(isolate); 13638 HandleScope scope(isolate);
13653 ASSERT(args.length() == 2); 13639 ASSERT(args.length() == 2);
13654 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 13640 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
13655 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); 13641 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1);
13656 13642
13643 MaybeHandle<Object> maybe_result;
13644 if (without_debugger) {
13645 maybe_result = Execution::Call(isolate,
13646 function,
13647 isolate->global_object(),
13648 0,
13649 NULL);
13650 } else {
13651 EnterDebugger enter_debugger(isolate);
13652 maybe_result = Execution::Call(isolate,
13653 function,
13654 isolate->global_object(),
13655 0,
13656 NULL);
13657 }
13657 Handle<Object> result; 13658 Handle<Object> result;
13658 bool pending_exception; 13659 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result);
13659 { 13660 return *result;
13660 if (without_debugger) {
13661 result = Execution::Call(isolate,
13662 function,
13663 isolate->global_object(),
13664 0,
13665 NULL,
13666 &pending_exception);
13667 } else {
13668 EnterDebugger enter_debugger(isolate);
13669 result = Execution::Call(isolate,
13670 function,
13671 isolate->global_object(),
13672 0,
13673 NULL,
13674 &pending_exception);
13675 }
13676 }
13677 if (!pending_exception) {
13678 return *result;
13679 } else {
13680 return Failure::Exception();
13681 }
13682 } 13661 }
13683 13662
13684 13663
13685 // Sets a v8 flag. 13664 // Sets a v8 flag.
13686 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { 13665 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) {
13687 SealHandleScope shs(isolate); 13666 SealHandleScope shs(isolate);
13688 CONVERT_ARG_CHECKED(String, arg, 0); 13667 CONVERT_ARG_CHECKED(String, arg, 0);
13689 SmartArrayPointer<char> flags = 13668 SmartArrayPointer<char> flags =
13690 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 13669 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
13691 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); 13670 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get()));
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
13996 ASSERT(args.length() == 3); 13975 ASSERT(args.length() == 3);
13997 13976
13998 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 13977 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
13999 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 13978 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
14000 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 13979 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
14001 13980
14002 Handle<ObjectTemplateInfo> date_format_template = 13981 Handle<ObjectTemplateInfo> date_format_template =
14003 I18N::GetTemplate(isolate); 13982 I18N::GetTemplate(isolate);
14004 13983
14005 // Create an empty object wrapper. 13984 // Create an empty object wrapper.
14006 bool has_pending_exception = false; 13985 Handle<JSObject> local_object;
14007 Handle<JSObject> local_object = Execution::InstantiateObject( 13986 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14008 date_format_template, &has_pending_exception); 13987 isolate, local_object,
14009 if (has_pending_exception) { 13988 Execution::InstantiateObject(date_format_template));
14010 ASSERT(isolate->has_pending_exception());
14011 return Failure::Exception();
14012 }
14013 13989
14014 // Set date time formatter as internal field of the resulting JS object. 13990 // Set date time formatter as internal field of the resulting JS object.
14015 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( 13991 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat(
14016 isolate, locale, options, resolved); 13992 isolate, locale, options, resolved);
14017 13993
14018 if (!date_format) return isolate->ThrowIllegalOperation(); 13994 if (!date_format) return isolate->ThrowIllegalOperation();
14019 13995
14020 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); 13996 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
14021 13997
14022 RETURN_IF_EMPTY_HANDLE(isolate, 13998 RETURN_IF_EMPTY_HANDLE(isolate,
(...skipping 13 matching lines...) Expand all
14036 14012
14037 14013
14038 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) { 14014 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) {
14039 HandleScope scope(isolate); 14015 HandleScope scope(isolate);
14040 14016
14041 ASSERT(args.length() == 2); 14017 ASSERT(args.length() == 2);
14042 14018
14043 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); 14019 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
14044 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); 14020 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1);
14045 14021
14046 bool has_pending_exception = false; 14022 Handle<Object> value;
14047 Handle<Object> value = 14023 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14048 Execution::ToNumber(isolate, date, &has_pending_exception); 14024 isolate, value, Execution::ToNumber(isolate, date));
14049 if (has_pending_exception) {
14050 ASSERT(isolate->has_pending_exception());
14051 return Failure::Exception();
14052 }
14053 14025
14054 icu::SimpleDateFormat* date_format = 14026 icu::SimpleDateFormat* date_format =
14055 DateFormat::UnpackDateFormat(isolate, date_format_holder); 14027 DateFormat::UnpackDateFormat(isolate, date_format_holder);
14056 if (!date_format) return isolate->ThrowIllegalOperation(); 14028 if (!date_format) return isolate->ThrowIllegalOperation();
14057 14029
14058 icu::UnicodeString result; 14030 icu::UnicodeString result;
14059 date_format->format(value->Number(), result); 14031 date_format->format(value->Number(), result);
14060 14032
14061 return *isolate->factory()->NewStringFromTwoByte( 14033 return *isolate->factory()->NewStringFromTwoByte(
14062 Vector<const uint16_t>( 14034 Vector<const uint16_t>(
(...skipping 13 matching lines...) Expand all
14076 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); 14048 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string));
14077 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); 14049 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date));
14078 icu::SimpleDateFormat* date_format = 14050 icu::SimpleDateFormat* date_format =
14079 DateFormat::UnpackDateFormat(isolate, date_format_holder); 14051 DateFormat::UnpackDateFormat(isolate, date_format_holder);
14080 if (!date_format) return isolate->ThrowIllegalOperation(); 14052 if (!date_format) return isolate->ThrowIllegalOperation();
14081 14053
14082 UErrorCode status = U_ZERO_ERROR; 14054 UErrorCode status = U_ZERO_ERROR;
14083 UDate date = date_format->parse(u_date, status); 14055 UDate date = date_format->parse(u_date, status);
14084 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); 14056 if (U_FAILURE(status)) return isolate->heap()->undefined_value();
14085 14057
14086 bool has_pending_exception = false; 14058 Handle<Object> result;
14087 Handle<JSDate> result = Handle<JSDate>::cast( 14059 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14088 Execution::NewDate( 14060 isolate, result,
14089 isolate, static_cast<double>(date), &has_pending_exception)); 14061 Execution::NewDate(isolate, static_cast<double>(date)));
14090 if (has_pending_exception) { 14062 ASSERT(result->IsJSDate());
14091 ASSERT(isolate->has_pending_exception());
14092 return Failure::Exception();
14093 }
14094 return *result; 14063 return *result;
14095 } 14064 }
14096 14065
14097 14066
14098 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { 14067 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) {
14099 HandleScope scope(isolate); 14068 HandleScope scope(isolate);
14100 14069
14101 ASSERT(args.length() == 3); 14070 ASSERT(args.length() == 3);
14102 14071
14103 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 14072 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
14104 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 14073 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
14105 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 14074 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
14106 14075
14107 Handle<ObjectTemplateInfo> number_format_template = 14076 Handle<ObjectTemplateInfo> number_format_template =
14108 I18N::GetTemplate(isolate); 14077 I18N::GetTemplate(isolate);
14109 14078
14110 // Create an empty object wrapper. 14079 // Create an empty object wrapper.
14111 bool has_pending_exception = false; 14080 Handle<JSObject> local_object;
14112 Handle<JSObject> local_object = Execution::InstantiateObject( 14081 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14113 number_format_template, &has_pending_exception); 14082 isolate, local_object,
14114 if (has_pending_exception) { 14083 Execution::InstantiateObject(number_format_template));
14115 ASSERT(isolate->has_pending_exception());
14116 return Failure::Exception();
14117 }
14118 14084
14119 // Set number formatter as internal field of the resulting JS object. 14085 // Set number formatter as internal field of the resulting JS object.
14120 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( 14086 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat(
14121 isolate, locale, options, resolved); 14087 isolate, locale, options, resolved);
14122 14088
14123 if (!number_format) return isolate->ThrowIllegalOperation(); 14089 if (!number_format) return isolate->ThrowIllegalOperation();
14124 14090
14125 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); 14091 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
14126 14092
14127 RETURN_IF_EMPTY_HANDLE(isolate, 14093 RETURN_IF_EMPTY_HANDLE(isolate,
(...skipping 12 matching lines...) Expand all
14140 14106
14141 14107
14142 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { 14108 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
14143 HandleScope scope(isolate); 14109 HandleScope scope(isolate);
14144 14110
14145 ASSERT(args.length() == 2); 14111 ASSERT(args.length() == 2);
14146 14112
14147 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); 14113 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
14148 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); 14114 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
14149 14115
14150 bool has_pending_exception = false; 14116 Handle<Object> value;
14151 Handle<Object> value = Execution::ToNumber( 14117 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14152 isolate, number, &has_pending_exception); 14118 isolate, value, Execution::ToNumber(isolate, number));
14153 if (has_pending_exception) {
14154 ASSERT(isolate->has_pending_exception());
14155 return Failure::Exception();
14156 }
14157 14119
14158 icu::DecimalFormat* number_format = 14120 icu::DecimalFormat* number_format =
14159 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); 14121 NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
14160 if (!number_format) return isolate->ThrowIllegalOperation(); 14122 if (!number_format) return isolate->ThrowIllegalOperation();
14161 14123
14162 icu::UnicodeString result; 14124 icu::UnicodeString result;
14163 number_format->format(value->Number(), result); 14125 number_format->format(value->Number(), result);
14164 14126
14165 return *isolate->factory()->NewStringFromTwoByte( 14127 return *isolate->factory()->NewStringFromTwoByte(
14166 Vector<const uint16_t>( 14128 Vector<const uint16_t>(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
14213 14175
14214 ASSERT(args.length() == 3); 14176 ASSERT(args.length() == 3);
14215 14177
14216 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 14178 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
14217 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 14179 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
14218 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 14180 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
14219 14181
14220 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); 14182 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate);
14221 14183
14222 // Create an empty object wrapper. 14184 // Create an empty object wrapper.
14223 bool has_pending_exception = false; 14185 Handle<JSObject> local_object;
14224 Handle<JSObject> local_object = Execution::InstantiateObject( 14186 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14225 collator_template, &has_pending_exception); 14187 isolate, local_object, Execution::InstantiateObject(collator_template));
14226 if (has_pending_exception) {
14227 ASSERT(isolate->has_pending_exception());
14228 return Failure::Exception();
14229 }
14230 14188
14231 // Set collator as internal field of the resulting JS object. 14189 // Set collator as internal field of the resulting JS object.
14232 icu::Collator* collator = Collator::InitializeCollator( 14190 icu::Collator* collator = Collator::InitializeCollator(
14233 isolate, locale, options, resolved); 14191 isolate, locale, options, resolved);
14234 14192
14235 if (!collator) return isolate->ThrowIllegalOperation(); 14193 if (!collator) return isolate->ThrowIllegalOperation();
14236 14194
14237 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); 14195 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
14238 14196
14239 RETURN_IF_EMPTY_HANDLE(isolate, 14197 RETURN_IF_EMPTY_HANDLE(isolate,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
14314 ASSERT(args.length() == 3); 14272 ASSERT(args.length() == 3);
14315 14273
14316 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); 14274 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
14317 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); 14275 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
14318 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); 14276 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
14319 14277
14320 Handle<ObjectTemplateInfo> break_iterator_template = 14278 Handle<ObjectTemplateInfo> break_iterator_template =
14321 I18N::GetTemplate2(isolate); 14279 I18N::GetTemplate2(isolate);
14322 14280
14323 // Create an empty object wrapper. 14281 // Create an empty object wrapper.
14324 bool has_pending_exception = false; 14282 Handle<JSObject> local_object;
14325 Handle<JSObject> local_object = Execution::InstantiateObject( 14283 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14326 break_iterator_template, &has_pending_exception); 14284 isolate, local_object,
14327 if (has_pending_exception) { 14285 Execution::InstantiateObject(break_iterator_template));
14328 ASSERT(isolate->has_pending_exception());
14329 return Failure::Exception();
14330 }
14331 14286
14332 // Set break iterator as internal field of the resulting JS object. 14287 // Set break iterator as internal field of the resulting JS object.
14333 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( 14288 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
14334 isolate, locale, options, resolved); 14289 isolate, locale, options, resolved);
14335 14290
14336 if (!break_iterator) return isolate->ThrowIllegalOperation(); 14291 if (!break_iterator) return isolate->ThrowIllegalOperation();
14337 14292
14338 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); 14293 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
14339 // Make sure that the pointer to adopted text is NULL. 14294 // Make sure that the pointer to adopted text is NULL.
14340 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); 14295 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
14671 Handle<Object> key_handle(key, isolate); 14626 Handle<Object> key_handle(key, isolate);
14672 Handle<Object> value; 14627 Handle<Object> value;
14673 { 14628 {
14674 Handle<JSFunction> factory(JSFunction::cast( 14629 Handle<JSFunction> factory(JSFunction::cast(
14675 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); 14630 cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
14676 // TODO(antonm): consider passing a receiver when constructing a cache. 14631 // TODO(antonm): consider passing a receiver when constructing a cache.
14677 Handle<Object> receiver(isolate->native_context()->global_object(), 14632 Handle<Object> receiver(isolate->native_context()->global_object(),
14678 isolate); 14633 isolate);
14679 // This handle is nor shared, nor used later, so it's safe. 14634 // This handle is nor shared, nor used later, so it's safe.
14680 Handle<Object> argv[] = { key_handle }; 14635 Handle<Object> argv[] = { key_handle };
14681 bool pending_exception; 14636 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14682 value = Execution::Call(isolate, 14637 isolate, value,
14683 factory, 14638 Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv));
14684 receiver,
14685 ARRAY_SIZE(argv),
14686 argv,
14687 &pending_exception);
14688 if (pending_exception) return Failure::Exception();
14689 } 14639 }
14690 14640
14691 #ifdef VERIFY_HEAP 14641 #ifdef VERIFY_HEAP
14692 if (FLAG_verify_heap) { 14642 if (FLAG_verify_heap) {
14693 cache_handle->JSFunctionResultCacheVerify(); 14643 cache_handle->JSFunctionResultCacheVerify();
14694 } 14644 }
14695 #endif 14645 #endif
14696 14646
14697 // Function invocation may have cleared the cache. Reread all the data. 14647 // Function invocation may have cleared the cache. Reread all the data.
14698 finger_index = cache_handle->finger_index(); 14648 finger_index = cache_handle->finger_index();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
14910 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); 14860 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0);
14911 bool old_state = isolate->microtask_pending(); 14861 bool old_state = isolate->microtask_pending();
14912 isolate->set_microtask_pending(new_state); 14862 isolate->set_microtask_pending(new_state);
14913 return isolate->heap()->ToBoolean(old_state); 14863 return isolate->heap()->ToBoolean(old_state);
14914 } 14864 }
14915 14865
14916 14866
14917 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) { 14867 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) {
14918 HandleScope scope(isolate); 14868 HandleScope scope(isolate);
14919 ASSERT(args.length() == 0); 14869 ASSERT(args.length() == 0);
14920 if (isolate->microtask_pending()) 14870 if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate);
14921 Execution::RunMicrotasks(isolate);
14922 return isolate->heap()->undefined_value(); 14871 return isolate->heap()->undefined_value();
14923 } 14872 }
14924 14873
14925 14874
14926 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetMicrotaskState) { 14875 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetMicrotaskState) {
14927 SealHandleScope shs(isolate); 14876 SealHandleScope shs(isolate);
14928 ASSERT(args.length() == 0); 14877 ASSERT(args.length() == 0);
14929 return isolate->heap()->microtask_state(); 14878 return isolate->heap()->microtask_state();
14930 } 14879 }
14931 14880
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
15238 } 15187 }
15239 } 15188 }
15240 15189
15241 15190
15242 void Runtime::OutOfMemory() { 15191 void Runtime::OutOfMemory() {
15243 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15192 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15244 UNREACHABLE(); 15193 UNREACHABLE();
15245 } 15194 }
15246 15195
15247 } } // namespace v8::internal 15196 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698