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

Side by Side Diff: src/runtime.cc

Issue 352813002: Wrap InitializeProperty around SetOwnPropertyIgnoreAttributes and switch over uses (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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') | no next file » | 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 // 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 } else { 297 } else {
298 // Non-uint32 number. 298 // Non-uint32 number.
299 ASSERT(key->IsNumber()); 299 ASSERT(key->IsNumber());
300 double num = key->Number(); 300 double num = key->Number();
301 char arr[100]; 301 char arr[100];
302 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 302 Vector<char> buffer(arr, ARRAY_SIZE(arr));
303 const char* str = DoubleToCString(num, buffer); 303 const char* str = DoubleToCString(num, buffer);
304 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); 304 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
305 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 305 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
306 boilerplate, name, value, NONE, 306 boilerplate, name, value, NONE, value_type, mode);
307 value_type, mode);
308 } 307 }
309 // If setting the property on the boilerplate throws an 308 // If setting the property on the boilerplate throws an
310 // exception, the exception is converted to an empty handle in 309 // exception, the exception is converted to an empty handle in
311 // the handle based operations. In that case, we need to 310 // the handle based operations. In that case, we need to
312 // convert back to an exception. 311 // convert back to an exception.
313 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); 312 RETURN_ON_EXCEPTION(isolate, maybe_result, Object);
314 } 313 }
315 314
316 // Transform to fast properties if necessary. For object literals with 315 // Transform to fast properties if necessary. For object literals with
317 // containing function literals we defer this operation until after all 316 // containing function literals we defer this operation until after all
(...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 2388
2390 // Lookup the property as own on the global object. If it isn't 2389 // Lookup the property as own on the global object. If it isn't
2391 // there, we add the property and take special precautions to always 2390 // there, we add the property and take special precautions to always
2392 // add it even in case of callbacks in the prototype chain (this rules 2391 // add it even in case of callbacks in the prototype chain (this rules
2393 // out using SetProperty). We use SetOwnPropertyIgnoreAttributes instead 2392 // out using SetProperty). We use SetOwnPropertyIgnoreAttributes instead
2394 LookupResult lookup(isolate); 2393 LookupResult lookup(isolate);
2395 global->LookupOwn(name, &lookup); 2394 global->LookupOwn(name, &lookup);
2396 if (!lookup.IsFound()) { 2395 if (!lookup.IsFound()) {
2397 HandleScope handle_scope(isolate); 2396 HandleScope handle_scope(isolate);
2398 Handle<GlobalObject> global(isolate->context()->global_object()); 2397 Handle<GlobalObject> global(isolate->context()->global_object());
2399 RETURN_FAILURE_ON_EXCEPTION( 2398 JSObject::AddProperty(global, name, value, attributes);
2400 isolate,
2401 JSObject::SetOwnPropertyIgnoreAttributes(global, name, value,
2402 attributes));
2403 return *value; 2399 return *value;
2404 } 2400 }
2405 2401
2406 if (!lookup.IsReadOnly()) { 2402 if (!lookup.IsReadOnly()) {
2407 // Restore global object from context (in case of GC) and continue 2403 // Restore global object from context (in case of GC) and continue
2408 // with setting the value. 2404 // with setting the value.
2409 HandleScope handle_scope(isolate); 2405 HandleScope handle_scope(isolate);
2410 Handle<GlobalObject> global(isolate->context()->global_object()); 2406 Handle<GlobalObject> global(isolate->context()->global_object());
2411 2407
2412 // BUG 1213575: Handle the case where we have to set a read-only 2408 // BUG 1213575: Handle the case where we have to set a read-only
(...skipping 5704 matching lines...) Expand 10 before | Expand all | Expand 10 after
8117 // is happy about the number of fields. 8113 // is happy about the number of fields.
8118 RUNTIME_ASSERT(bound_function->RemovePrototype()); 8114 RUNTIME_ASSERT(bound_function->RemovePrototype());
8119 Handle<Map> bound_function_map( 8115 Handle<Map> bound_function_map(
8120 isolate->native_context()->bound_function_map()); 8116 isolate->native_context()->bound_function_map());
8121 JSObject::MigrateToMap(bound_function, bound_function_map); 8117 JSObject::MigrateToMap(bound_function, bound_function_map);
8122 Handle<String> length_string = isolate->factory()->length_string(); 8118 Handle<String> length_string = isolate->factory()->length_string();
8123 PropertyAttributes attr = 8119 PropertyAttributes attr =
8124 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); 8120 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY);
8125 RETURN_FAILURE_ON_EXCEPTION( 8121 RETURN_FAILURE_ON_EXCEPTION(
8126 isolate, 8122 isolate,
8127 JSObject::SetOwnPropertyIgnoreAttributes(bound_function, length_string, 8123 JSObject::SetOwnPropertyIgnoreAttributes(
8128 new_length, attr)); 8124 bound_function, length_string, new_length, attr));
8129 return *bound_function; 8125 return *bound_function;
8130 } 8126 }
8131 8127
8132 8128
8133 RUNTIME_FUNCTION(Runtime_BoundFunctionGetBindings) { 8129 RUNTIME_FUNCTION(Runtime_BoundFunctionGetBindings) {
8134 HandleScope handles(isolate); 8130 HandleScope handles(isolate);
8135 ASSERT(args.length() == 1); 8131 ASSERT(args.length() == 1);
8136 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); 8132 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0);
8137 if (callable->IsJSFunction()) { 8133 if (callable->IsJSFunction()) {
8138 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); 8134 Handle<JSFunction> function = Handle<JSFunction>::cast(callable);
(...skipping 5654 matching lines...) Expand 10 before | Expand all | Expand 10 after
13793 // de_DE -> de-DE 13789 // de_DE -> de-DE
13794 char base_locale[ULOC_FULLNAME_CAPACITY]; 13790 char base_locale[ULOC_FULLNAME_CAPACITY];
13795 uloc_toLanguageTag( 13791 uloc_toLanguageTag(
13796 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error); 13792 icu_base_locale, base_locale, ULOC_FULLNAME_CAPACITY, FALSE, &error);
13797 13793
13798 if (U_FAILURE(error)) { 13794 if (U_FAILURE(error)) {
13799 return isolate->Throw(*factory->illegal_argument_string()); 13795 return isolate->Throw(*factory->illegal_argument_string());
13800 } 13796 }
13801 13797
13802 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); 13798 Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
13803 RETURN_FAILURE_ON_EXCEPTION(isolate, 13799 Handle<String> value = factory->NewStringFromAsciiChecked(base_max_locale);
13804 JSObject::SetOwnPropertyIgnoreAttributes( 13800 JSObject::AddProperty(result, maximized, value, NONE);
13805 result, 13801 value = factory->NewStringFromAsciiChecked(base_locale);
13806 maximized, 13802 JSObject::AddProperty(result, base, value, NONE);
13807 factory->NewStringFromAsciiChecked(base_max_locale),
13808 NONE));
13809 RETURN_FAILURE_ON_EXCEPTION(isolate,
13810 JSObject::SetOwnPropertyIgnoreAttributes(
13811 result,
13812 base,
13813 factory->NewStringFromAsciiChecked(base_locale),
13814 NONE));
13815 output->set(i, *result); 13803 output->set(i, *result);
13816 } 13804 }
13817 13805
13818 Handle<JSArray> result = factory->NewJSArrayWithElements(output); 13806 Handle<JSArray> result = factory->NewJSArrayWithElements(output);
13819 result->set_length(Smi::FromInt(length)); 13807 result->set_length(Smi::FromInt(length));
13820 return *result; 13808 return *result;
13821 } 13809 }
13822 13810
13823 13811
13824 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { 13812 RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
13921 Execution::InstantiateObject(date_format_template)); 13909 Execution::InstantiateObject(date_format_template));
13922 13910
13923 // Set date time formatter as internal field of the resulting JS object. 13911 // Set date time formatter as internal field of the resulting JS object.
13924 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat( 13912 icu::SimpleDateFormat* date_format = DateFormat::InitializeDateTimeFormat(
13925 isolate, locale, options, resolved); 13913 isolate, locale, options, resolved);
13926 13914
13927 if (!date_format) return isolate->ThrowIllegalOperation(); 13915 if (!date_format) return isolate->ThrowIllegalOperation();
13928 13916
13929 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format)); 13917 local_object->SetInternalField(0, reinterpret_cast<Smi*>(date_format));
13930 13918
13931 RETURN_FAILURE_ON_EXCEPTION(isolate, 13919 Factory* factory = isolate->factory();
13932 JSObject::SetOwnPropertyIgnoreAttributes( 13920 Handle<String> key = factory->NewStringFromStaticAscii("dateFormat");
13933 local_object, 13921 Handle<String> value = factory->NewStringFromStaticAscii("valid");
13934 isolate->factory()->NewStringFromStaticAscii("dateFormat"), 13922 JSObject::AddProperty(local_object, key, value, NONE);
13935 isolate->factory()->NewStringFromStaticAscii("valid"),
13936 NONE));
13937 13923
13938 // Make object handle weak so we can delete the data format once GC kicks in. 13924 // Make object handle weak so we can delete the data format once GC kicks in.
13939 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 13925 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
13940 GlobalHandles::MakeWeak(wrapper.location(), 13926 GlobalHandles::MakeWeak(wrapper.location(),
13941 reinterpret_cast<void*>(wrapper.location()), 13927 reinterpret_cast<void*>(wrapper.location()),
13942 DateFormat::DeleteDateFormat); 13928 DateFormat::DeleteDateFormat);
13943 return *local_object; 13929 return *local_object;
13944 } 13930 }
13945 13931
13946 13932
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
14020 Execution::InstantiateObject(number_format_template)); 14006 Execution::InstantiateObject(number_format_template));
14021 14007
14022 // Set number formatter as internal field of the resulting JS object. 14008 // Set number formatter as internal field of the resulting JS object.
14023 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat( 14009 icu::DecimalFormat* number_format = NumberFormat::InitializeNumberFormat(
14024 isolate, locale, options, resolved); 14010 isolate, locale, options, resolved);
14025 14011
14026 if (!number_format) return isolate->ThrowIllegalOperation(); 14012 if (!number_format) return isolate->ThrowIllegalOperation();
14027 14013
14028 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format)); 14014 local_object->SetInternalField(0, reinterpret_cast<Smi*>(number_format));
14029 14015
14030 RETURN_FAILURE_ON_EXCEPTION(isolate, 14016 Factory* factory = isolate->factory();
14031 JSObject::SetOwnPropertyIgnoreAttributes( 14017 Handle<String> key = factory->NewStringFromStaticAscii("numberFormat");
14032 local_object, 14018 Handle<String> value = factory->NewStringFromStaticAscii("valid");
14033 isolate->factory()->NewStringFromStaticAscii("numberFormat"), 14019 JSObject::AddProperty(local_object, key, value, NONE);
14034 isolate->factory()->NewStringFromStaticAscii("valid"),
14035 NONE));
14036 14020
14037 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 14021 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14038 GlobalHandles::MakeWeak(wrapper.location(), 14022 GlobalHandles::MakeWeak(wrapper.location(),
14039 reinterpret_cast<void*>(wrapper.location()), 14023 reinterpret_cast<void*>(wrapper.location()),
14040 NumberFormat::DeleteNumberFormat); 14024 NumberFormat::DeleteNumberFormat);
14041 return *local_object; 14025 return *local_object;
14042 } 14026 }
14043 14027
14044 14028
14045 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { 14029 RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
14128 isolate, local_object, Execution::InstantiateObject(collator_template)); 14112 isolate, local_object, Execution::InstantiateObject(collator_template));
14129 14113
14130 // Set collator as internal field of the resulting JS object. 14114 // Set collator as internal field of the resulting JS object.
14131 icu::Collator* collator = Collator::InitializeCollator( 14115 icu::Collator* collator = Collator::InitializeCollator(
14132 isolate, locale, options, resolved); 14116 isolate, locale, options, resolved);
14133 14117
14134 if (!collator) return isolate->ThrowIllegalOperation(); 14118 if (!collator) return isolate->ThrowIllegalOperation();
14135 14119
14136 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator)); 14120 local_object->SetInternalField(0, reinterpret_cast<Smi*>(collator));
14137 14121
14138 RETURN_FAILURE_ON_EXCEPTION(isolate, 14122 Factory* factory = isolate->factory();
14139 JSObject::SetOwnPropertyIgnoreAttributes( 14123 Handle<String> key = factory->NewStringFromStaticAscii("collator");
14140 local_object, 14124 Handle<String> value = factory->NewStringFromStaticAscii("valid");
14141 isolate->factory()->NewStringFromStaticAscii("collator"), 14125 JSObject::AddProperty(local_object, key, value, NONE);
14142 isolate->factory()->NewStringFromStaticAscii("valid"),
14143 NONE));
14144 14126
14145 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 14127 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14146 GlobalHandles::MakeWeak(wrapper.location(), 14128 GlobalHandles::MakeWeak(wrapper.location(),
14147 reinterpret_cast<void*>(wrapper.location()), 14129 reinterpret_cast<void*>(wrapper.location()),
14148 Collator::DeleteCollator); 14130 Collator::DeleteCollator);
14149 return *local_object; 14131 return *local_object;
14150 } 14132 }
14151 14133
14152 14134
14153 RUNTIME_FUNCTION(Runtime_InternalCompare) { 14135 RUNTIME_FUNCTION(Runtime_InternalCompare) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
14234 // Set break iterator as internal field of the resulting JS object. 14216 // Set break iterator as internal field of the resulting JS object.
14235 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator( 14217 icu::BreakIterator* break_iterator = BreakIterator::InitializeBreakIterator(
14236 isolate, locale, options, resolved); 14218 isolate, locale, options, resolved);
14237 14219
14238 if (!break_iterator) return isolate->ThrowIllegalOperation(); 14220 if (!break_iterator) return isolate->ThrowIllegalOperation();
14239 14221
14240 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator)); 14222 local_object->SetInternalField(0, reinterpret_cast<Smi*>(break_iterator));
14241 // Make sure that the pointer to adopted text is NULL. 14223 // Make sure that the pointer to adopted text is NULL.
14242 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL)); 14224 local_object->SetInternalField(1, reinterpret_cast<Smi*>(NULL));
14243 14225
14244 RETURN_FAILURE_ON_EXCEPTION(isolate, 14226 Factory* factory = isolate->factory();
14245 JSObject::SetOwnPropertyIgnoreAttributes( 14227 Handle<String> key = factory->NewStringFromStaticAscii("breakIterator");
14246 local_object, 14228 Handle<String> value = factory->NewStringFromStaticAscii("valid");
14247 isolate->factory()->NewStringFromStaticAscii("breakIterator"), 14229 JSObject::AddProperty(local_object, key, value, NONE);
14248 isolate->factory()->NewStringFromStaticAscii("valid"),
14249 NONE));
14250 14230
14251 // Make object handle weak so we can delete the break iterator once GC kicks 14231 // Make object handle weak so we can delete the break iterator once GC kicks
14252 // in. 14232 // in.
14253 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); 14233 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
14254 GlobalHandles::MakeWeak(wrapper.location(), 14234 GlobalHandles::MakeWeak(wrapper.location(),
14255 reinterpret_cast<void*>(wrapper.location()), 14235 reinterpret_cast<void*>(wrapper.location()),
14256 BreakIterator::DeleteBreakIterator); 14236 BreakIterator::DeleteBreakIterator);
14257 return *local_object; 14237 return *local_object;
14258 } 14238 }
14259 14239
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
15090 } 15070 }
15091 return NULL; 15071 return NULL;
15092 } 15072 }
15093 15073
15094 15074
15095 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15075 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15096 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15076 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15097 } 15077 }
15098 15078
15099 } } // namespace v8::internal 15079 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698