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

Side by Side Diff: src/runtime.cc

Issue 294022: Add optimized ICs for new CanvasArray types. This is a follow-on CL to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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') | src/x64/assembler-x64.h » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 2562 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 HandleVector(args, 2)); 2573 HandleVector(args, 2));
2574 return Top::Throw(*error); 2574 return Top::Throw(*error);
2575 } 2575 }
2576 2576
2577 // Check if the given key is an array index. 2577 // Check if the given key is an array index.
2578 uint32_t index; 2578 uint32_t index;
2579 if (Array::IndexFromObject(*key, &index)) { 2579 if (Array::IndexFromObject(*key, &index)) {
2580 return GetElementOrCharAt(object, index); 2580 return GetElementOrCharAt(object, index);
2581 } 2581 }
2582 2582
2583 // If the target object is a JSObject and has an ExternalArray as
2584 // its elements, we need to check for negative indices and report
2585 // exceptions. Indices larger than the array's length will be caught
2586 // elsewhere.
2587 if (key->IsSmi() && Smi::cast(*key)->value() < 0) {
2588 if (object->IsJSObject() &&
2589 JSObject::cast(*object)->HasExternalArrayElements()) {
2590 uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value());
2591 return Top::Throw(*Factory::NewIndexError(index));
2592 }
2593 }
2594
2595 // Convert the key to a string - possibly by calling back into JavaScript. 2583 // Convert the key to a string - possibly by calling back into JavaScript.
2596 Handle<String> name; 2584 Handle<String> name;
2597 if (key->IsString()) { 2585 if (key->IsString()) {
2598 name = Handle<String>::cast(key); 2586 name = Handle<String>::cast(key);
2599 } else { 2587 } else {
2600 bool has_pending_exception = false; 2588 bool has_pending_exception = false;
2601 Handle<Object> converted = 2589 Handle<Object> converted =
2602 Execution::ToString(key, &has_pending_exception); 2590 Execution::ToString(key, &has_pending_exception);
2603 if (has_pending_exception) return Failure::Exception(); 2591 if (has_pending_exception) return Failure::Exception();
2604 name = Handle<String>::cast(converted); 2592 name = Handle<String>::cast(converted);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 // assignments. 2707 // assignments.
2720 if (js_object->IsStringObjectWithCharacterAt(index)) { 2708 if (js_object->IsStringObjectWithCharacterAt(index)) {
2721 return *value; 2709 return *value;
2722 } 2710 }
2723 2711
2724 Handle<Object> result = SetElement(js_object, index, value); 2712 Handle<Object> result = SetElement(js_object, index, value);
2725 if (result.is_null()) return Failure::Exception(); 2713 if (result.is_null()) return Failure::Exception();
2726 return *value; 2714 return *value;
2727 } 2715 }
2728 2716
2729 // If the target object is a JSObject and has an ExternalArray as
2730 // its elements, we need to check for negative indices and report
2731 // exceptions. Indices larger than the array's length will be caught
2732 // elsewhere.
2733 if (key->IsSmi() && Smi::cast(*key)->value() < 0) {
2734 if (object->IsJSObject() &&
2735 JSObject::cast(*object)->HasExternalArrayElements()) {
2736 uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value());
2737 return Top::Throw(*Factory::NewIndexError(index));
2738 }
2739 }
2740
2741 if (key->IsString()) { 2717 if (key->IsString()) {
2742 Handle<Object> result; 2718 Handle<Object> result;
2743 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { 2719 if (Handle<String>::cast(key)->AsArrayIndex(&index)) {
2744 ASSERT(attr == NONE); 2720 ASSERT(attr == NONE);
2745 result = SetElement(js_object, index, value); 2721 result = SetElement(js_object, index, value);
2746 } else { 2722 } else {
2747 Handle<String> key_string = Handle<String>::cast(key); 2723 Handle<String> key_string = Handle<String>::cast(key);
2748 key_string->TryFlattenIfNotFlat(); 2724 key_string->TryFlattenIfNotFlat();
2749 result = SetProperty(js_object, key_string, value, attr); 2725 result = SetProperty(js_object, key_string, value, attr);
2750 } 2726 }
(...skipping 5119 matching lines...) Expand 10 before | Expand all | Expand 10 after
7870 } else { 7846 } else {
7871 // Handle last resort GC and make sure to allow future allocations 7847 // Handle last resort GC and make sure to allow future allocations
7872 // to grow the heap without causing GCs (if possible). 7848 // to grow the heap without causing GCs (if possible).
7873 Counters::gc_last_resort_from_js.Increment(); 7849 Counters::gc_last_resort_from_js.Increment();
7874 Heap::CollectAllGarbage(false); 7850 Heap::CollectAllGarbage(false);
7875 } 7851 }
7876 } 7852 }
7877 7853
7878 7854
7879 } } // namespace v8::internal 7855 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698