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

Side by Side Diff: src/runtime.cc

Issue 409603002: Reduce usage of StoreMode. (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
« src/objects.cc ('K') | « 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // The value contains the constant_properties of a 260 // The value contains the constant_properties of a
261 // simple object or array literal. 261 // simple object or array literal.
262 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 262 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
263 ASSIGN_RETURN_ON_EXCEPTION( 263 ASSIGN_RETURN_ON_EXCEPTION(
264 isolate, value, 264 isolate, value,
265 CreateLiteralBoilerplate(isolate, literals, array), 265 CreateLiteralBoilerplate(isolate, literals, array),
266 Object); 266 Object);
267 } 267 }
268 MaybeHandle<Object> maybe_result; 268 MaybeHandle<Object> maybe_result;
269 uint32_t element_index = 0; 269 uint32_t element_index = 0;
270 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT;
271 if (key->IsInternalizedString()) { 270 if (key->IsInternalizedString()) {
272 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 271 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
273 // Array index as string (uint32). 272 // Array index as string (uint32).
274 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 273 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
275 maybe_result = 274 maybe_result =
276 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 275 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
277 } else { 276 } else {
278 Handle<String> name(String::cast(*key)); 277 Handle<String> name(String::cast(*key));
279 ASSERT(!name->AsArrayIndex(&element_index)); 278 ASSERT(!name->AsArrayIndex(&element_index));
280 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 279 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(
281 boilerplate, name, value, NONE, mode); 280 boilerplate, name, value, NONE);
282 } 281 }
283 } else if (key->ToArrayIndex(&element_index)) { 282 } else if (key->ToArrayIndex(&element_index)) {
284 // Array index (uint32). 283 // Array index (uint32).
285 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 284 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
286 maybe_result = 285 maybe_result =
287 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 286 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
288 } else { 287 } else {
289 // Non-uint32 number. 288 // Non-uint32 number.
290 ASSERT(key->IsNumber()); 289 ASSERT(key->IsNumber());
291 double num = key->Number(); 290 double num = key->Number();
292 char arr[100]; 291 char arr[100];
293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 292 Vector<char> buffer(arr, ARRAY_SIZE(arr));
294 const char* str = DoubleToCString(num, buffer); 293 const char* str = DoubleToCString(num, buffer);
295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); 294 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( 295 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
297 boilerplate, name, value, NONE, mode); 296 value, NONE);
298 } 297 }
299 // If setting the property on the boilerplate throws an 298 // If setting the property on the boilerplate throws an
300 // exception, the exception is converted to an empty handle in 299 // exception, the exception is converted to an empty handle in
301 // the handle based operations. In that case, we need to 300 // the handle based operations. In that case, we need to
302 // convert back to an exception. 301 // convert back to an exception.
303 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); 302 RETURN_ON_EXCEPTION(isolate, maybe_result, Object);
304 } 303 }
305 304
306 // Transform to fast properties if necessary. For object literals with 305 // Transform to fast properties if necessary. For object literals with
307 // containing function literals we defer this operation until after all 306 // containing function literals we defer this operation until after all
(...skipping 4656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4964 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); 4963 JSObject::NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
4965 } 4964 }
4966 4965
4967 // Use IgnoreAttributes version since a readonly property may be 4966 // Use IgnoreAttributes version since a readonly property may be
4968 // overridden and SetProperty does not allow this. 4967 // overridden and SetProperty does not allow this.
4969 Handle<Object> result; 4968 Handle<Object> result;
4970 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 4969 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
4971 isolate, result, 4970 isolate, result,
4972 JSObject::SetOwnPropertyIgnoreAttributes( 4971 JSObject::SetOwnPropertyIgnoreAttributes(
4973 js_object, name, obj_value, attr, 4972 js_object, name, obj_value, attr,
4974 ALLOW_AS_CONSTANT,
4975 JSReceiver::PERFORM_EXTENSIBILITY_CHECK, 4973 JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
4976 JSReceiver::MAY_BE_STORE_FROM_KEYED, 4974 JSReceiver::MAY_BE_STORE_FROM_KEYED,
4977 JSObject::DONT_FORCE_FIELD)); 4975 JSObject::DONT_FORCE_FIELD));
4978 return *result; 4976 return *result;
4979 } 4977 }
4980 4978
4981 Handle<Object> result; 4979 Handle<Object> result;
4982 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 4980 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
4983 isolate, result, 4981 isolate, result,
4984 Runtime::DefineObjectProperty( 4982 Runtime::DefineObjectProperty(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
5117 } 5115 }
5118 5116
5119 if (key->IsName()) { 5117 if (key->IsName()) {
5120 Handle<Name> name = Handle<Name>::cast(key); 5118 Handle<Name> name = Handle<Name>::cast(key);
5121 if (name->AsArrayIndex(&index)) { 5119 if (name->AsArrayIndex(&index)) {
5122 return JSObject::SetElement(js_object, index, value, attr, 5120 return JSObject::SetElement(js_object, index, value, attr,
5123 SLOPPY, false, DEFINE_PROPERTY); 5121 SLOPPY, false, DEFINE_PROPERTY);
5124 } else { 5122 } else {
5125 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); 5123 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name));
5126 return JSObject::SetOwnPropertyIgnoreAttributes( 5124 return JSObject::SetOwnPropertyIgnoreAttributes(
5127 js_object, name, value, attr, ALLOW_AS_CONSTANT, 5125 js_object, name, value, attr, JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
5128 JSReceiver::PERFORM_EXTENSIBILITY_CHECK, store_from_keyed); 5126 store_from_keyed);
5129 } 5127 }
5130 } 5128 }
5131 5129
5132 // Call-back into JavaScript to convert the key to a string. 5130 // Call-back into JavaScript to convert the key to a string.
5133 Handle<Object> converted; 5131 Handle<Object> converted;
5134 ASSIGN_RETURN_ON_EXCEPTION( 5132 ASSIGN_RETURN_ON_EXCEPTION(
5135 isolate, converted, Execution::ToString(isolate, key), Object); 5133 isolate, converted, Execution::ToString(isolate, key), Object);
5136 Handle<String> name = Handle<String>::cast(converted); 5134 Handle<String> name = Handle<String>::cast(converted);
5137 5135
5138 if (name->AsArrayIndex(&index)) { 5136 if (name->AsArrayIndex(&index)) {
5139 return JSObject::SetElement(js_object, index, value, attr, 5137 return JSObject::SetElement(js_object, index, value, attr,
5140 SLOPPY, false, DEFINE_PROPERTY); 5138 SLOPPY, false, DEFINE_PROPERTY);
5141 } else { 5139 } else {
5142 return JSObject::SetOwnPropertyIgnoreAttributes( 5140 return JSObject::SetOwnPropertyIgnoreAttributes(
5143 js_object, name, value, attr, ALLOW_AS_CONSTANT, 5141 js_object, name, value, attr, JSReceiver::PERFORM_EXTENSIBILITY_CHECK,
5144 JSReceiver::PERFORM_EXTENSIBILITY_CHECK, store_from_keyed); 5142 store_from_keyed);
5145 } 5143 }
5146 } 5144 }
5147 5145
5148 5146
5149 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, 5147 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
5150 Handle<JSReceiver> receiver, 5148 Handle<JSReceiver> receiver,
5151 Handle<Object> key, 5149 Handle<Object> key,
5152 JSReceiver::DeleteMode mode) { 5150 JSReceiver::DeleteMode mode) {
5153 // Check if the given key is an array index. 5151 // Check if the given key is an array index.
5154 uint32_t index; 5152 uint32_t index;
(...skipping 9811 matching lines...) Expand 10 before | Expand all | Expand 10 after
14966 } 14964 }
14967 return NULL; 14965 return NULL;
14968 } 14966 }
14969 14967
14970 14968
14971 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 14969 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
14972 return &(kIntrinsicFunctions[static_cast<int>(id)]); 14970 return &(kIntrinsicFunctions[static_cast<int>(id)]);
14973 } 14971 }
14974 14972
14975 } } // namespace v8::internal 14973 } } // namespace v8::internal
OLDNEW
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698