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

Side by Side Diff: src/runtime.cc

Issue 227573002: Return MaybeHandle from SetElement and DeleteElement. (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
« src/api.cc ('K') | « src/runtime.h ('k') | src/scopes.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 4927 matching lines...) Expand 10 before | Expand all | Expand 10 after
4938 } else { 4938 } else {
4939 bool has_pending_exception = false; 4939 bool has_pending_exception = false;
4940 Handle<Object> converted = 4940 Handle<Object> converted =
4941 Execution::ToString(isolate, key, &has_pending_exception); 4941 Execution::ToString(isolate, key, &has_pending_exception);
4942 if (has_pending_exception) return Handle<Name>(); 4942 if (has_pending_exception) return Handle<Name>();
4943 return Handle<Name>::cast(converted); 4943 return Handle<Name>::cast(converted);
4944 } 4944 }
4945 } 4945 }
4946 4946
4947 4947
4948 MaybeObject* Runtime::HasObjectProperty(Isolate* isolate, 4948 MaybeHandle<Object> Runtime::HasObjectProperty(Isolate* isolate,
4949 Handle<JSReceiver> object, 4949 Handle<JSReceiver> object,
4950 Handle<Object> key) { 4950 Handle<Object> key) {
4951 HandleScope scope(isolate);
4952
4953 // Check if the given key is an array index. 4951 // Check if the given key is an array index.
4954 uint32_t index; 4952 uint32_t index;
4955 if (key->ToArrayIndex(&index)) { 4953 if (key->ToArrayIndex(&index)) {
4956 return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index)); 4954 return isolate->factory()->ToBoolean(JSReceiver::HasElement(object, index));
4957 } 4955 }
4958 4956
4959 // Convert the key to a name - possibly by calling back into JavaScript. 4957 // Convert the key to a name - possibly by calling back into JavaScript.
4960 Handle<Name> name = ToName(isolate, key); 4958 Handle<Name> name = ToName(isolate, key);
4961 RETURN_IF_EMPTY_HANDLE(isolate, name); 4959 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>());
4962 4960
4963 return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name)); 4961 return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name));
4964 } 4962 }
4965 4963
4966 4964
4967 Handle<Object> Runtime::GetObjectProperty(Isolate* isolate, 4965 Handle<Object> Runtime::GetObjectProperty(Isolate* isolate,
4968 Handle<Object> object, 4966 Handle<Object> object,
4969 Handle<Object> key) { 4967 Handle<Object> key) {
4970 if (object->IsUndefined() || object->IsNull()) { 4968 if (object->IsUndefined() || object->IsNull()) {
4971 Handle<Object> args[2] = { key, object }; 4969 Handle<Object> args[2] = { key, object };
4972 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load", 4970 isolate->Throw(*isolate->factory()->NewTypeError("non_object_property_load",
4973 HandleVector(args, 2))); 4971 HandleVector(args, 2)));
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 isolate->factory()->NewTypeError("non_object_property_store", 5267 isolate->factory()->NewTypeError("non_object_property_store",
5270 HandleVector(args, 2)); 5268 HandleVector(args, 2));
5271 isolate->Throw(*error); 5269 isolate->Throw(*error);
5272 return Handle<Object>(); 5270 return Handle<Object>();
5273 } 5271 }
5274 5272
5275 if (object->IsJSProxy()) { 5273 if (object->IsJSProxy()) {
5276 bool has_pending_exception = false; 5274 bool has_pending_exception = false;
5277 Handle<Object> name_object = key->IsSymbol() 5275 Handle<Object> name_object = key->IsSymbol()
5278 ? key : Execution::ToString(isolate, key, &has_pending_exception); 5276 ? key : Execution::ToString(isolate, key, &has_pending_exception);
5279 if (has_pending_exception) return Handle<Object>(); // exception 5277 if (has_pending_exception) return MaybeHandle<Object>(); // exception
5280 Handle<Name> name = Handle<Name>::cast(name_object); 5278 Handle<Name> name = Handle<Name>::cast(name_object);
5281 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value, 5279 return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
5282 attr, 5280 attr,
5283 strict_mode); 5281 strict_mode);
5284 } 5282 }
5285 5283
5286 // If the object isn't a JavaScript object, we ignore the store. 5284 // If the object isn't a JavaScript object, we ignore the store.
5287 if (!object->IsJSObject()) return value; 5285 if (!object->IsJSObject()) return value;
5288 5286
5289 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 5287 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
(...skipping 12 matching lines...) Expand all
5302 return value; 5300 return value;
5303 } 5301 }
5304 5302
5305 js_object->ValidateElements(); 5303 js_object->ValidateElements();
5306 if (js_object->HasExternalArrayElements() || 5304 if (js_object->HasExternalArrayElements() ||
5307 js_object->HasFixedTypedArrayElements()) { 5305 js_object->HasFixedTypedArrayElements()) {
5308 if (!value->IsNumber() && !value->IsUndefined()) { 5306 if (!value->IsNumber() && !value->IsUndefined()) {
5309 bool has_exception; 5307 bool has_exception;
5310 Handle<Object> number = 5308 Handle<Object> number =
5311 Execution::ToNumber(isolate, value, &has_exception); 5309 Execution::ToNumber(isolate, value, &has_exception);
5312 if (has_exception) return Handle<Object>(); // exception 5310 if (has_exception) return MaybeHandle<Object>(); // exception
5313 value = number; 5311 value = number;
5314 } 5312 }
5315 } 5313 }
5316 Handle<Object> result = JSObject::SetElement(js_object, index, value, attr, 5314 MaybeHandle<Object> result =
5317 strict_mode, 5315 JSObject::SetElement(js_object, index, value, attr,
Igor Sheludko 2014/04/07 15:32:31 I would fix identation of this line.
Yang 2014/04/08 06:51:42 Done.
5318 true, 5316 strict_mode, true, set_mode);
5319 set_mode);
5320 js_object->ValidateElements(); 5317 js_object->ValidateElements();
5321 return result.is_null() ? result : value; 5318 return result.is_null() ? result : value;
5322 } 5319 }
5323 5320
5324 if (key->IsName()) { 5321 if (key->IsName()) {
5325 Handle<Name> name = Handle<Name>::cast(key); 5322 Handle<Name> name = Handle<Name>::cast(key);
5326 if (name->AsArrayIndex(&index)) { 5323 if (name->AsArrayIndex(&index)) {
5327 if (js_object->HasExternalArrayElements()) { 5324 if (js_object->HasExternalArrayElements()) {
5328 if (!value->IsNumber() && !value->IsUndefined()) { 5325 if (!value->IsNumber() && !value->IsUndefined()) {
5329 bool has_exception; 5326 bool has_exception;
5330 Handle<Object> number = 5327 Handle<Object> number =
5331 Execution::ToNumber(isolate, value, &has_exception); 5328 Execution::ToNumber(isolate, value, &has_exception);
5332 if (has_exception) return Handle<Object>(); // exception 5329 if (has_exception) return MaybeHandle<Object>(); // exception
5333 value = number; 5330 value = number;
5334 } 5331 }
5335 } 5332 }
5336 return JSObject::SetElement(js_object, index, value, attr, strict_mode, 5333 return JSObject::SetElement(js_object, index, value, attr,
5337 true, 5334 strict_mode, true, set_mode);
5338 set_mode);
5339 } else { 5335 } else {
5340 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5336 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5341 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5337 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5342 } 5338 }
5343 } 5339 }
5344 5340
5345 // Call-back into JavaScript to convert the key to a string. 5341 // Call-back into JavaScript to convert the key to a string.
5346 bool has_pending_exception = false; 5342 bool has_pending_exception = false;
5347 Handle<Object> converted = 5343 Handle<Object> converted =
5348 Execution::ToString(isolate, key, &has_pending_exception); 5344 Execution::ToString(isolate, key, &has_pending_exception);
5349 if (has_pending_exception) return Handle<Object>(); // exception 5345 if (has_pending_exception) return MaybeHandle<Object>(); // exception
5350 Handle<String> name = Handle<String>::cast(converted); 5346 Handle<String> name = Handle<String>::cast(converted);
5351 5347
5352 if (name->AsArrayIndex(&index)) { 5348 if (name->AsArrayIndex(&index)) {
5353 return JSObject::SetElement(js_object, index, value, attr, strict_mode, 5349 return JSObject::SetElement(js_object, index, value, attr,
5354 true, 5350 strict_mode, true, set_mode);
5355 set_mode);
5356 } else { 5351 } else {
5357 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode); 5352 return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
5358 } 5353 }
5359 } 5354 }
5360 5355
5361 5356
5362 MaybeHandle<Object> Runtime::ForceSetObjectProperty(Handle<JSObject> js_object, 5357 MaybeHandle<Object> Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
5363 Handle<Object> key, 5358 Handle<Object> key,
5364 Handle<Object> value, 5359 Handle<Object> value,
5365 PropertyAttributes attr) { 5360 PropertyAttributes attr) {
5366 Isolate* isolate = js_object->GetIsolate(); 5361 Isolate* isolate = js_object->GetIsolate();
5367 // Check if the given key is an array index. 5362 // Check if the given key is an array index.
5368 uint32_t index; 5363 uint32_t index;
5369 if (key->ToArrayIndex(&index)) { 5364 if (key->ToArrayIndex(&index)) {
5370 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters 5365 // In Firefox/SpiderMonkey, Safari and Opera you can access the characters
5371 // of a string using [] notation. We need to support this too in 5366 // of a string using [] notation. We need to support this too in
5372 // JavaScript. 5367 // JavaScript.
5373 // In the case of a String object we just need to redirect the assignment to 5368 // In the case of a String object we just need to redirect the assignment to
5374 // the underlying string if the index is in range. Since the underlying 5369 // the underlying string if the index is in range. Since the underlying
5375 // string does nothing with the assignment then we can ignore such 5370 // string does nothing with the assignment then we can ignore such
5376 // assignments. 5371 // assignments.
5377 if (js_object->IsStringObjectWithCharacterAt(index)) { 5372 if (js_object->IsStringObjectWithCharacterAt(index)) {
5378 return value; 5373 return value;
5379 } 5374 }
5380 5375
5381 return JSObject::SetElement(js_object, index, value, attr, SLOPPY, 5376 return JSObject::SetElement(js_object, index, value, attr,
5382 false, 5377 SLOPPY, false, DEFINE_PROPERTY);
5383 DEFINE_PROPERTY);
5384 } 5378 }
5385 5379
5386 if (key->IsName()) { 5380 if (key->IsName()) {
5387 Handle<Name> name = Handle<Name>::cast(key); 5381 Handle<Name> name = Handle<Name>::cast(key);
5388 if (name->AsArrayIndex(&index)) { 5382 if (name->AsArrayIndex(&index)) {
5389 return JSObject::SetElement(js_object, index, value, attr, SLOPPY, 5383 return JSObject::SetElement(js_object, index, value, attr,
5390 false, 5384 SLOPPY, false, DEFINE_PROPERTY);
5391 DEFINE_PROPERTY);
5392 } else { 5385 } else {
5393 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5386 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5394 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, 5387 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name,
5395 value, attr); 5388 value, attr);
5396 } 5389 }
5397 } 5390 }
5398 5391
5399 // Call-back into JavaScript to convert the key to a string. 5392 // Call-back into JavaScript to convert the key to a string.
5400 bool has_pending_exception = false; 5393 bool has_pending_exception = false;
5401 Handle<Object> converted = 5394 Handle<Object> converted =
5402 Execution::ToString(isolate, key, &has_pending_exception); 5395 Execution::ToString(isolate, key, &has_pending_exception);
5403 if (has_pending_exception) return Handle<Object>(); // exception 5396 if (has_pending_exception) return MaybeHandle<Object>(); // exception
5404 Handle<String> name = Handle<String>::cast(converted); 5397 Handle<String> name = Handle<String>::cast(converted);
5405 5398
5406 if (name->AsArrayIndex(&index)) { 5399 if (name->AsArrayIndex(&index)) {
5407 return JSObject::SetElement(js_object, index, value, attr, SLOPPY, 5400 return JSObject::SetElement(js_object, index, value, attr,
5408 false, 5401 SLOPPY, false, DEFINE_PROPERTY);
5409 DEFINE_PROPERTY);
5410 } else { 5402 } else {
5411 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value, 5403 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
5412 attr); 5404 attr);
5413 } 5405 }
5414 } 5406 }
5415 5407
5416 5408
5417 MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate, 5409 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
5418 Handle<JSReceiver> receiver, 5410 Handle<JSReceiver> receiver,
5419 Handle<Object> key, 5411 Handle<Object> key,
5420 JSReceiver::DeleteMode mode) { 5412 JSReceiver::DeleteMode mode) {
5421 HandleScope scope(isolate);
5422
5423 // Check if the given key is an array index. 5413 // Check if the given key is an array index.
5424 uint32_t index; 5414 uint32_t index;
5425 if (key->ToArrayIndex(&index)) { 5415 if (key->ToArrayIndex(&index)) {
5426 // In Firefox/SpiderMonkey, Safari and Opera you can access the 5416 // In Firefox/SpiderMonkey, Safari and Opera you can access the
5427 // characters of a string using [] notation. In the case of a 5417 // characters of a string using [] notation. In the case of a
5428 // String object we just need to redirect the deletion to the 5418 // String object we just need to redirect the deletion to the
5429 // underlying string if the index is in range. Since the 5419 // underlying string if the index is in range. Since the
5430 // underlying string does nothing with the deletion, we can ignore 5420 // underlying string does nothing with the deletion, we can ignore
5431 // such deletions. 5421 // such deletions.
5432 if (receiver->IsStringObjectWithCharacterAt(index)) { 5422 if (receiver->IsStringObjectWithCharacterAt(index)) {
5433 return isolate->heap()->true_value(); 5423 return isolate->factory()->true_value();
5434 } 5424 }
5435 5425
5436 Handle<Object> result = JSReceiver::DeleteElement(receiver, index, mode); 5426 return JSReceiver::DeleteElement(receiver, index, mode);
5437 RETURN_IF_EMPTY_HANDLE(isolate, result);
5438 return *result;
5439 } 5427 }
5440 5428
5441 Handle<Name> name; 5429 Handle<Name> name;
5442 if (key->IsName()) { 5430 if (key->IsName()) {
5443 name = Handle<Name>::cast(key); 5431 name = Handle<Name>::cast(key);
5444 } else { 5432 } else {
5445 // Call-back into JavaScript to convert the key to a string. 5433 // Call-back into JavaScript to convert the key to a string.
5446 bool has_pending_exception = false; 5434 bool has_pending_exception = false;
5447 Handle<Object> converted = Execution::ToString( 5435 Handle<Object> converted = Execution::ToString(
5448 isolate, key, &has_pending_exception); 5436 isolate, key, &has_pending_exception);
5449 if (has_pending_exception) return Failure::Exception(); 5437 if (has_pending_exception) return MaybeHandle<Object>();
5450 name = Handle<String>::cast(converted); 5438 name = Handle<String>::cast(converted);
5451 } 5439 }
5452 5440
5453 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5441 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5454 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode); 5442 return JSReceiver::DeleteProperty(receiver, name, mode);
5455 RETURN_IF_EMPTY_HANDLE(isolate, result);
5456 return *result;
5457 } 5443 }
5458 5444
5459 5445
5460 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) { 5446 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) {
5461 HandleScope scope(isolate); 5447 HandleScope scope(isolate);
5462 RUNTIME_ASSERT(args.length() == 3); 5448 RUNTIME_ASSERT(args.length() == 3);
5463 5449
5464 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 5450 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
5465 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); 5451 CONVERT_ARG_HANDLE_CHECKED(String, key, 1);
5466 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5452 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
5661 5647
5662 5648
5663 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { 5649 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) {
5664 HandleScope scope(isolate); 5650 HandleScope scope(isolate);
5665 ASSERT(args.length() == 3); 5651 ASSERT(args.length() == 3);
5666 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); 5652 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0);
5667 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); 5653 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
5668 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); 5654 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
5669 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT 5655 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT
5670 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; 5656 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
5671 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode); 5657 Handle<Object> result;
5672 RETURN_IF_EMPTY_HANDLE(isolate, result); 5658 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
5659 isolate, result,
5660 JSReceiver::DeleteProperty(object, key, delete_mode));
5673 return *result; 5661 return *result;
5674 } 5662 }
5675 5663
5676 5664
5677 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, 5665 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate,
5678 Handle<JSObject> object, 5666 Handle<JSObject> object,
5679 Handle<Name> key) { 5667 Handle<Name> key) {
5680 if (JSReceiver::HasLocalProperty(object, key)) { 5668 if (JSReceiver::HasLocalProperty(object, key)) {
5681 return isolate->heap()->true_value(); 5669 return isolate->heap()->true_value();
5682 } 5670 }
(...skipping 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after
9235 9223
9236 // If the slot was found in a context, it should be DONT_DELETE. 9224 // If the slot was found in a context, it should be DONT_DELETE.
9237 if (holder->IsContext()) { 9225 if (holder->IsContext()) {
9238 return isolate->heap()->false_value(); 9226 return isolate->heap()->false_value();
9239 } 9227 }
9240 9228
9241 // The slot was found in a JSObject, either a context extension object, 9229 // The slot was found in a JSObject, either a context extension object,
9242 // the global object, or the subject of a with. Try to delete it 9230 // the global object, or the subject of a with. Try to delete it
9243 // (respecting DONT_DELETE). 9231 // (respecting DONT_DELETE).
9244 Handle<JSObject> object = Handle<JSObject>::cast(holder); 9232 Handle<JSObject> object = Handle<JSObject>::cast(holder);
9245 Handle<Object> result = JSReceiver::DeleteProperty(object, name); 9233 Handle<Object> result;
9246 RETURN_IF_EMPTY_HANDLE(isolate, result); 9234 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
9235 isolate, result,
9236 JSReceiver::DeleteProperty(object, name));
9247 return *result; 9237 return *result;
9248 } 9238 }
9249 9239
9250 9240
9251 // A mechanism to return a pair of Object pointers in registers (if possible). 9241 // A mechanism to return a pair of Object pointers in registers (if possible).
9252 // How this is achieved is calling convention-dependent. 9242 // How this is achieved is calling convention-dependent.
9253 // All currently supported x86 compiles uses calling conventions that are cdecl 9243 // All currently supported x86 compiles uses calling conventions that are cdecl
9254 // variants where a 64-bit value is returned in two 32-bit registers 9244 // variants where a 64-bit value is returned in two 32-bit registers
9255 // (edx:eax on ia32, r1:r0 on ARM). 9245 // (edx:eax on ia32, r1:r0 on ARM).
9256 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. 9246 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax.
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
9951 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); 9941 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
9952 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); 9942 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1);
9953 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); 9943 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
9954 int length = Smi::cast(array->length())->value(); 9944 int length = Smi::cast(array->length())->value();
9955 FixedArray* elements = FixedArray::cast(array->elements()); 9945 FixedArray* elements = FixedArray::cast(array->elements());
9956 for (int i = 0; i < length; i++) { 9946 for (int i = 0; i < length; i++) {
9957 if (elements->get(i) == *element) return isolate->heap()->false_value(); 9947 if (elements->get(i) == *element) return isolate->heap()->false_value();
9958 } 9948 }
9959 9949
9960 // Strict not needed. Used for cycle detection in Array join implementation. 9950 // Strict not needed. Used for cycle detection in Array join implementation.
9961 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length, 9951 RETURN_FAILURE_ON_EXCEPTION(
9962 element, 9952 isolate,
9963 SLOPPY, 9953 JSObject::SetFastElement(array, length, element, SLOPPY, true));
9964 true));
9965 return isolate->heap()->true_value(); 9954 return isolate->heap()->true_value();
9966 } 9955 }
9967 9956
9968 9957
9969 /** 9958 /**
9970 * A simple visitor visits every element of Array's. 9959 * A simple visitor visits every element of Array's.
9971 * The backend storage can be a fixed array for fast elements case, 9960 * The backend storage can be a fixed array for fast elements case,
9972 * or a dictionary for sparse array. Since Dictionary is a subtype 9961 * or a dictionary for sparse array. Since Dictionary is a subtype
9973 * of FixedArray, the class can be used by both fast and slow cases. 9962 * of FixedArray, the class can be used by both fast and slow cases.
9974 * The second parameter of the constructor, fast_elements, specifies 9963 * The second parameter of the constructor, fast_elements, specifies
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after
12310 } else { 12299 } else {
12311 JavaScriptFrameIterator additional_frame_it(isolate, break_frame_id); 12300 JavaScriptFrameIterator additional_frame_it(isolate, break_frame_id);
12312 // If our frame is a top frame and we are stepping, we can do step-in 12301 // If our frame is a top frame and we are stepping, we can do step-in
12313 // at this place. 12302 // at this place.
12314 accept = additional_frame_it.frame()->id() == id; 12303 accept = additional_frame_it.frame()->id() == id;
12315 } 12304 }
12316 } 12305 }
12317 if (accept) { 12306 if (accept) {
12318 if (break_location_iterator.IsStepInLocation(isolate)) { 12307 if (break_location_iterator.IsStepInLocation(isolate)) {
12319 Smi* position_value = Smi::FromInt(break_location_iterator.position()); 12308 Smi* position_value = Smi::FromInt(break_location_iterator.position());
12320 JSObject::SetElement(array, len, 12309 RETURN_FAILURE_ON_EXCEPTION(
12321 Handle<Object>(position_value, isolate), 12310 isolate,
12322 NONE, SLOPPY); 12311 JSObject::SetElement(array, len,
12312 Handle<Object>(position_value, isolate),
12313 NONE, SLOPPY));
12323 len++; 12314 len++;
12324 } 12315 }
12325 } 12316 }
12326 // Advance iterator. 12317 // Advance iterator.
12327 break_location_iterator.Next(); 12318 break_location_iterator.Next();
12328 if (current_statement_pos != 12319 if (current_statement_pos !=
12329 break_location_iterator.statement_position()) { 12320 break_location_iterator.statement_position()) {
12330 break; 12321 break;
12331 } 12322 }
12332 } 12323 }
(...skipping 2926 matching lines...) Expand 10 before | Expand all | Expand 10 after
15259 } 15250 }
15260 } 15251 }
15261 15252
15262 15253
15263 void Runtime::OutOfMemory() { 15254 void Runtime::OutOfMemory() {
15264 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15255 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15265 UNREACHABLE(); 15256 UNREACHABLE();
15266 } 15257 }
15267 15258
15268 } } // namespace v8::internal 15259 } } // namespace v8::internal
OLDNEW
« src/api.cc ('K') | « src/runtime.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698