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

Side by Side Diff: src/objects.cc

Issue 151603004: A64: Synchronize with r16587. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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.h ('k') | src/objects-debug.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "accessors.h" 30 #include "accessors.h"
31 #include "api.h" 31 #include "api.h"
32 #include "arguments.h" 32 #include "arguments.h"
33 #include "bootstrapper.h" 33 #include "bootstrapper.h"
34 #include "codegen.h" 34 #include "codegen.h"
35 #include "cpu-profiler.h"
35 #include "debug.h" 36 #include "debug.h"
36 #include "deoptimizer.h" 37 #include "deoptimizer.h"
37 #include "date.h" 38 #include "date.h"
38 #include "elements.h" 39 #include "elements.h"
39 #include "execution.h" 40 #include "execution.h"
40 #include "full-codegen.h" 41 #include "full-codegen.h"
41 #include "hydrogen.h" 42 #include "hydrogen.h"
42 #include "isolate-inl.h" 43 #include "isolate-inl.h"
44 #include "log.h"
43 #include "objects-inl.h" 45 #include "objects-inl.h"
44 #include "objects-visiting.h" 46 #include "objects-visiting.h"
45 #include "objects-visiting-inl.h" 47 #include "objects-visiting-inl.h"
46 #include "macro-assembler.h" 48 #include "macro-assembler.h"
47 #include "mark-compact.h" 49 #include "mark-compact.h"
48 #include "safepoint-table.h" 50 #include "safepoint-table.h"
49 #include "string-stream.h" 51 #include "string-stream.h"
50 #include "utils.h" 52 #include "utils.h"
51 53
52 #ifdef ENABLE_DISASSEMBLER 54 #ifdef ENABLE_DISASSEMBLER
(...skipping 23 matching lines...) Expand all
76 } else if (IsBoolean()) { 78 } else if (IsBoolean()) {
77 return CreateJSValue(native_context->boolean_function(), this); 79 return CreateJSValue(native_context->boolean_function(), this);
78 } else if (IsString()) { 80 } else if (IsString()) {
79 return CreateJSValue(native_context->string_function(), this); 81 return CreateJSValue(native_context->string_function(), this);
80 } 82 }
81 ASSERT(IsJSObject()); 83 ASSERT(IsJSObject());
82 return this; 84 return this;
83 } 85 }
84 86
85 87
86 MaybeObject* Object::ToObject() { 88 MaybeObject* Object::ToObject(Isolate* isolate) {
87 if (IsJSReceiver()) { 89 if (IsJSReceiver()) {
88 return this; 90 return this;
89 } else if (IsNumber()) { 91 } else if (IsNumber()) {
90 Isolate* isolate = Isolate::Current();
91 Context* native_context = isolate->context()->native_context(); 92 Context* native_context = isolate->context()->native_context();
92 return CreateJSValue(native_context->number_function(), this); 93 return CreateJSValue(native_context->number_function(), this);
93 } else if (IsBoolean()) { 94 } else if (IsBoolean()) {
94 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
95 Context* native_context = isolate->context()->native_context(); 95 Context* native_context = isolate->context()->native_context();
96 return CreateJSValue(native_context->boolean_function(), this); 96 return CreateJSValue(native_context->boolean_function(), this);
97 } else if (IsString()) { 97 } else if (IsString()) {
98 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
99 Context* native_context = isolate->context()->native_context(); 98 Context* native_context = isolate->context()->native_context();
100 return CreateJSValue(native_context->string_function(), this); 99 return CreateJSValue(native_context->string_function(), this);
101 } else if (IsSymbol()) { 100 } else if (IsSymbol()) {
102 Isolate* isolate = HeapObject::cast(this)->GetIsolate();
103 Context* native_context = isolate->context()->native_context(); 101 Context* native_context = isolate->context()->native_context();
104 return CreateJSValue(native_context->symbol_function(), this); 102 return CreateJSValue(native_context->symbol_function(), this);
105 } 103 }
106 104
107 // Throw a type error. 105 // Throw a type error.
108 return Failure::InternalError(); 106 return Failure::InternalError();
109 } 107 }
110 108
111 109
112 bool Object::BooleanValue() { 110 bool Object::BooleanValue() {
(...skipping 15 matching lines...) Expand all
128 Context* native_context = result->isolate()->context()->native_context(); 126 Context* native_context = result->isolate()->context()->native_context();
129 if (IsNumber()) { 127 if (IsNumber()) {
130 holder = native_context->number_function()->instance_prototype(); 128 holder = native_context->number_function()->instance_prototype();
131 } else if (IsString()) { 129 } else if (IsString()) {
132 holder = native_context->string_function()->instance_prototype(); 130 holder = native_context->string_function()->instance_prototype();
133 } else if (IsSymbol()) { 131 } else if (IsSymbol()) {
134 holder = native_context->symbol_function()->instance_prototype(); 132 holder = native_context->symbol_function()->instance_prototype();
135 } else if (IsBoolean()) { 133 } else if (IsBoolean()) {
136 holder = native_context->boolean_function()->instance_prototype(); 134 holder = native_context->boolean_function()->instance_prototype();
137 } else { 135 } else {
138 Isolate::Current()->PushStackTraceAndDie( 136 result->isolate()->PushStackTraceAndDie(
139 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001); 137 0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001);
140 } 138 }
141 } 139 }
142 ASSERT(holder != NULL); // Cannot handle null or undefined. 140 ASSERT(holder != NULL); // Cannot handle null or undefined.
143 JSReceiver::cast(holder)->Lookup(name, result); 141 JSReceiver::cast(holder)->Lookup(name, result);
144 } 142 }
145 143
146 144
147 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver, 145 MaybeObject* Object::GetPropertyWithReceiver(Object* receiver,
148 Name* name, 146 Name* name,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 413
416 Handle<Object> args[] = { receiver, name }; 414 Handle<Object> args[] = { receiver, name };
417 Handle<Object> result = CallTrap( 415 Handle<Object> result = CallTrap(
418 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args); 416 "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args);
419 if (isolate->has_pending_exception()) return Failure::Exception(); 417 if (isolate->has_pending_exception()) return Failure::Exception();
420 418
421 return *result; 419 return *result;
422 } 420 }
423 421
424 422
425 Handle<Object> Object::GetProperty(Handle<Object> object, Handle<Name> name) { 423 Handle<Object> Object::GetProperty(Handle<Object> object,
424 Handle<Name> name) {
426 // TODO(rossberg): The index test should not be here but in the GetProperty 425 // TODO(rossberg): The index test should not be here but in the GetProperty
427 // method (or somewhere else entirely). Needs more global clean-up. 426 // method (or somewhere else entirely). Needs more global clean-up.
428 uint32_t index; 427 uint32_t index;
428 Isolate* isolate = name->GetIsolate();
429 if (name->AsArrayIndex(&index)) 429 if (name->AsArrayIndex(&index))
430 return GetElement(object, index); 430 return GetElement(isolate, object, index);
431 Isolate* isolate = object->IsHeapObject()
432 ? Handle<HeapObject>::cast(object)->GetIsolate()
433 : Isolate::Current();
434 CALL_HEAP_FUNCTION(isolate, object->GetProperty(*name), Object); 431 CALL_HEAP_FUNCTION(isolate, object->GetProperty(*name), Object);
435 } 432 }
436 433
437 434
438 Handle<Object> Object::GetElement(Handle<Object> object, uint32_t index) { 435 Handle<Object> Object::GetElement(Isolate* isolate,
439 Isolate* isolate = object->IsHeapObject() 436 Handle<Object> object,
440 ? Handle<HeapObject>::cast(object)->GetIsolate() 437 uint32_t index) {
441 : Isolate::Current(); 438 CALL_HEAP_FUNCTION(isolate, object->GetElement(isolate, index), Object);
442 CALL_HEAP_FUNCTION(isolate, object->GetElement(index), Object);
443 } 439 }
444 440
445 441
446 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver, 442 MaybeObject* JSProxy::GetElementWithHandler(Object* receiver,
447 uint32_t index) { 443 uint32_t index) {
448 String* name; 444 String* name;
449 MaybeObject* maybe = GetHeap()->Uint32ToString(index); 445 MaybeObject* maybe = GetHeap()->Uint32ToString(index);
450 if (!maybe->To<String>(&name)) return maybe; 446 if (!maybe->To<String>(&name)) return maybe;
451 return GetPropertyWithHandler(receiver, name); 447 return GetPropertyWithHandler(receiver, name);
452 } 448 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 Debug* debug = isolate->debug(); 480 Debug* debug = isolate->debug();
485 // Handle stepping into a getter if step into is active. 481 // Handle stepping into a getter if step into is active.
486 // TODO(rossberg): should this apply to getters that are function proxies? 482 // TODO(rossberg): should this apply to getters that are function proxies?
487 if (debug->StepInActive() && fun->IsJSFunction()) { 483 if (debug->StepInActive() && fun->IsJSFunction()) {
488 debug->HandleStepIn( 484 debug->HandleStepIn(
489 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false); 485 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false);
490 } 486 }
491 #endif 487 #endif
492 488
493 bool has_pending_exception; 489 bool has_pending_exception;
494 Handle<Object> result = 490 Handle<Object> result = Execution::Call(
495 Execution::Call(fun, self, 0, NULL, &has_pending_exception, true); 491 isolate, fun, self, 0, NULL, &has_pending_exception, true);
496 // Check for pending exception and return the result. 492 // Check for pending exception and return the result.
497 if (has_pending_exception) return Failure::Exception(); 493 if (has_pending_exception) return Failure::Exception();
498 return *result; 494 return *result;
499 } 495 }
500 496
501 497
502 // Only deal with CALLBACKS and INTERCEPTOR 498 // Only deal with CALLBACKS and INTERCEPTOR
503 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck( 499 MaybeObject* JSObject::GetPropertyWithFailedAccessCheck(
504 Object* receiver, 500 Object* receiver,
505 LookupResult* result, 501 LookupResult* result,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 || !HasFastObjectElements() 790 || !HasFastObjectElements()
795 || !HasFastProperties(); 791 || !HasFastProperties();
796 } 792 }
797 793
798 794
799 Handle<Object> Object::GetProperty(Handle<Object> object, 795 Handle<Object> Object::GetProperty(Handle<Object> object,
800 Handle<Object> receiver, 796 Handle<Object> receiver,
801 LookupResult* result, 797 LookupResult* result,
802 Handle<Name> key, 798 Handle<Name> key,
803 PropertyAttributes* attributes) { 799 PropertyAttributes* attributes) {
804 Isolate* isolate = object->IsHeapObject() 800 Isolate* isolate = result->isolate();
805 ? Handle<HeapObject>::cast(object)->GetIsolate()
806 : Isolate::Current();
807 CALL_HEAP_FUNCTION( 801 CALL_HEAP_FUNCTION(
808 isolate, 802 isolate,
809 object->GetProperty(*receiver, result, *key, attributes), 803 object->GetProperty(*receiver, result, *key, attributes),
810 Object); 804 Object);
811 } 805 }
812 806
813 807
814 MaybeObject* Object::GetPropertyOrFail(Handle<Object> object, 808 MaybeObject* Object::GetPropertyOrFail(Handle<Object> object,
815 Handle<Object> receiver, 809 Handle<Object> receiver,
816 LookupResult* result, 810 LookupResult* result,
817 Handle<Name> key, 811 Handle<Name> key,
818 PropertyAttributes* attributes) { 812 PropertyAttributes* attributes) {
819 Isolate* isolate = object->IsHeapObject() 813 Isolate* isolate = result->isolate();
820 ? Handle<HeapObject>::cast(object)->GetIsolate()
821 : Isolate::Current();
822 CALL_HEAP_FUNCTION_PASS_EXCEPTION( 814 CALL_HEAP_FUNCTION_PASS_EXCEPTION(
823 isolate, 815 isolate,
824 object->GetProperty(*receiver, result, *key, attributes)); 816 object->GetProperty(*receiver, result, *key, attributes));
825 } 817 }
826 818
827 819
828 MaybeObject* Object::GetProperty(Object* receiver, 820 MaybeObject* Object::GetProperty(Object* receiver,
829 LookupResult* result, 821 LookupResult* result,
830 Name* name, 822 Name* name,
831 PropertyAttributes* attributes) { 823 PropertyAttributes* attributes) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 case TRANSITION: 895 case TRANSITION:
904 case NONEXISTENT: 896 case NONEXISTENT:
905 UNREACHABLE(); 897 UNREACHABLE();
906 break; 898 break;
907 } 899 }
908 UNREACHABLE(); 900 UNREACHABLE();
909 return NULL; 901 return NULL;
910 } 902 }
911 903
912 904
913 MaybeObject* Object::GetElementWithReceiver(Object* receiver, uint32_t index) { 905 MaybeObject* Object::GetElementWithReceiver(Isolate* isolate,
914 Isolate* isolate = IsSmi() 906 Object* receiver,
915 ? Isolate::Current() 907 uint32_t index) {
916 : HeapObject::cast(this)->GetIsolate();
917 Heap* heap = isolate->heap(); 908 Heap* heap = isolate->heap();
918 Object* holder = this; 909 Object* holder = this;
919 910
920 // Iterate up the prototype chain until an element is found or the null 911 // Iterate up the prototype chain until an element is found or the null
921 // prototype is encountered. 912 // prototype is encountered.
922 for (holder = this; 913 for (holder = this;
923 holder != heap->null_value(); 914 holder != heap->null_value();
924 holder = holder->GetPrototype(isolate)) { 915 holder = holder->GetPrototype(isolate)) {
925 if (!holder->IsJSObject()) { 916 if (!holder->IsJSObject()) {
926 Context* native_context = isolate->context()->native_context(); 917 Context* native_context = isolate->context()->native_context();
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 Handle<Name> name, 2084 Handle<Name> name,
2094 Handle<Object> old_value) { 2085 Handle<Object> old_value) {
2095 Isolate* isolate = object->GetIsolate(); 2086 Isolate* isolate = object->GetIsolate();
2096 HandleScope scope(isolate); 2087 HandleScope scope(isolate);
2097 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str); 2088 Handle<String> type = isolate->factory()->InternalizeUtf8String(type_str);
2098 if (object->IsJSGlobalObject()) { 2089 if (object->IsJSGlobalObject()) {
2099 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate); 2090 object = handle(JSGlobalObject::cast(*object)->global_receiver(), isolate);
2100 } 2091 }
2101 Handle<Object> args[] = { type, object, name, old_value }; 2092 Handle<Object> args[] = { type, object, name, old_value };
2102 bool threw; 2093 bool threw;
2103 Execution::Call(Handle<JSFunction>(isolate->observers_notify_change()), 2094 Execution::Call(isolate,
2095 Handle<JSFunction>(isolate->observers_notify_change()),
2104 isolate->factory()->undefined_value(), 2096 isolate->factory()->undefined_value(),
2105 old_value->IsTheHole() ? 3 : 4, args, 2097 old_value->IsTheHole() ? 3 : 4, args,
2106 &threw); 2098 &threw);
2107 ASSERT(!threw); 2099 ASSERT(!threw);
2108 } 2100 }
2109 2101
2110 2102
2111 void JSObject::DeliverChangeRecords(Isolate* isolate) { 2103 void JSObject::DeliverChangeRecords(Isolate* isolate) {
2112 ASSERT(isolate->observer_delivery_pending()); 2104 ASSERT(isolate->observer_delivery_pending());
2113 bool threw = false; 2105 bool threw = false;
2114 Execution::Call( 2106 Execution::Call(
2107 isolate,
2115 isolate->observers_deliver_changes(), 2108 isolate->observers_deliver_changes(),
2116 isolate->factory()->undefined_value(), 2109 isolate->factory()->undefined_value(),
2117 0, 2110 0,
2118 NULL, 2111 NULL,
2119 &threw); 2112 &threw);
2120 ASSERT(!threw); 2113 ASSERT(!threw);
2121 isolate->set_observer_delivery_pending(false); 2114 isolate->set_observer_delivery_pending(false);
2122 } 2115 }
2123 2116
2124 2117
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
2881 Debug* debug = isolate->debug(); 2874 Debug* debug = isolate->debug();
2882 // Handle stepping into a setter if step into is active. 2875 // Handle stepping into a setter if step into is active.
2883 // TODO(rossberg): should this apply to getters that are function proxies? 2876 // TODO(rossberg): should this apply to getters that are function proxies?
2884 if (debug->StepInActive() && fun->IsJSFunction()) { 2877 if (debug->StepInActive() && fun->IsJSFunction()) {
2885 debug->HandleStepIn( 2878 debug->HandleStepIn(
2886 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false); 2879 Handle<JSFunction>::cast(fun), Handle<Object>::null(), 0, false);
2887 } 2880 }
2888 #endif 2881 #endif
2889 bool has_pending_exception; 2882 bool has_pending_exception;
2890 Handle<Object> argv[] = { value_handle }; 2883 Handle<Object> argv[] = { value_handle };
2891 Execution::Call(fun, self, ARRAY_SIZE(argv), argv, &has_pending_exception); 2884 Execution::Call(
2885 isolate, fun, self, ARRAY_SIZE(argv), argv, &has_pending_exception);
2892 // Check for pending exception and return the result. 2886 // Check for pending exception and return the result.
2893 if (has_pending_exception) return Failure::Exception(); 2887 if (has_pending_exception) return Failure::Exception();
2894 return *value_handle; 2888 return *value_handle;
2895 } 2889 }
2896 2890
2897 2891
2898 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes( 2892 MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(
2899 uint32_t index, 2893 uint32_t index,
2900 Object* value, 2894 Object* value,
2901 bool* found, 2895 bool* found,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 DescriptorArray::WhitenessWitness witness(*new_descriptors); 2999 DescriptorArray::WhitenessWitness witness(*new_descriptors);
3006 3000
3007 for (int i = 0; i < number_of_descriptors; ++i) { 3001 for (int i = 0; i < number_of_descriptors; ++i) {
3008 new_descriptors->CopyFrom(i, *descriptors, i, witness); 3002 new_descriptors->CopyFrom(i, *descriptors, i, witness);
3009 } 3003 }
3010 3004
3011 map->set_instance_descriptors(*new_descriptors); 3005 map->set_instance_descriptors(*new_descriptors);
3012 } 3006 }
3013 3007
3014 3008
3015 void Map::AppendCallbackDescriptors(Handle<Map> map, 3009 template<class T>
3016 Handle<Object> descriptors) { 3010 static int AppendUniqueCallbacks(NeanderArray* callbacks,
3017 Isolate* isolate = map->GetIsolate(); 3011 Handle<typename T::Array> array,
3018 Handle<DescriptorArray> array(map->instance_descriptors()); 3012 int valid_descriptors) {
3019 NeanderArray callbacks(descriptors); 3013 int nof_callbacks = callbacks->length();
3020 int nof_callbacks = callbacks.length();
3021 3014
3022 ASSERT(array->NumberOfSlackDescriptors() >= nof_callbacks); 3015 Isolate* isolate = array->GetIsolate();
3023
3024 // Ensure the keys are unique names before writing them into the 3016 // Ensure the keys are unique names before writing them into the
3025 // instance descriptor. Since it may cause a GC, it has to be done before we 3017 // instance descriptor. Since it may cause a GC, it has to be done before we
3026 // temporarily put the heap in an invalid state while appending descriptors. 3018 // temporarily put the heap in an invalid state while appending descriptors.
3027 for (int i = 0; i < nof_callbacks; ++i) { 3019 for (int i = 0; i < nof_callbacks; ++i) {
3028 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks.get(i))); 3020 Handle<AccessorInfo> entry(AccessorInfo::cast(callbacks->get(i)));
3029 if (!entry->name()->IsUniqueName()) { 3021 if (entry->name()->IsUniqueName()) continue;
3030 Handle<String> key = 3022 Handle<String> key =
3031 isolate->factory()->InternalizedStringFromString( 3023 isolate->factory()->InternalizedStringFromString(
3032 Handle<String>(String::cast(entry->name()))); 3024 Handle<String>(String::cast(entry->name())));
3033 entry->set_name(*key); 3025 entry->set_name(*key);
3034 }
3035 } 3026 }
3036 3027
3037 int nof = map->NumberOfOwnDescriptors();
3038
3039 // Fill in new callback descriptors. Process the callbacks from 3028 // Fill in new callback descriptors. Process the callbacks from
3040 // back to front so that the last callback with a given name takes 3029 // back to front so that the last callback with a given name takes
3041 // precedence over previously added callbacks with that name. 3030 // precedence over previously added callbacks with that name.
3042 for (int i = nof_callbacks - 1; i >= 0; i--) { 3031 for (int i = nof_callbacks - 1; i >= 0; i--) {
3043 AccessorInfo* entry = AccessorInfo::cast(callbacks.get(i)); 3032 AccessorInfo* entry = AccessorInfo::cast(callbacks->get(i));
3044 Name* key = Name::cast(entry->name()); 3033 Name* key = Name::cast(entry->name());
3045 // Check if a descriptor with this name already exists before writing. 3034 // Check if a descriptor with this name already exists before writing.
3046 if (array->Search(key, nof) == DescriptorArray::kNotFound) { 3035 if (!T::Contains(key, entry, valid_descriptors, array)) {
3047 CallbacksDescriptor desc(key, entry, entry->property_attributes()); 3036 T::Insert(key, entry, valid_descriptors, array);
3048 array->Append(&desc); 3037 valid_descriptors++;
3049 nof += 1;
3050 } 3038 }
3051 } 3039 }
3052 3040
3041 return valid_descriptors;
3042 }
3043
3044 struct DescriptorArrayAppender {
3045 typedef DescriptorArray Array;
3046 static bool Contains(Name* key,
3047 AccessorInfo* entry,
3048 int valid_descriptors,
3049 Handle<DescriptorArray> array) {
3050 return array->Search(key, valid_descriptors) != DescriptorArray::kNotFound;
3051 }
3052 static void Insert(Name* key,
3053 AccessorInfo* entry,
3054 int valid_descriptors,
3055 Handle<DescriptorArray> array) {
3056 CallbacksDescriptor desc(key, entry, entry->property_attributes());
3057 array->Append(&desc);
3058 }
3059 };
3060
3061
3062 struct FixedArrayAppender {
3063 typedef FixedArray Array;
3064 static bool Contains(Name* key,
3065 AccessorInfo* entry,
3066 int valid_descriptors,
3067 Handle<FixedArray> array) {
3068 for (int i = 0; i < valid_descriptors; i++) {
3069 if (key == AccessorInfo::cast(array->get(i))->name()) return true;
3070 }
3071 return false;
3072 }
3073 static void Insert(Name* key,
3074 AccessorInfo* entry,
3075 int valid_descriptors,
3076 Handle<FixedArray> array) {
3077 array->set(valid_descriptors, entry);
3078 }
3079 };
3080
3081
3082 void Map::AppendCallbackDescriptors(Handle<Map> map,
3083 Handle<Object> descriptors) {
3084 int nof = map->NumberOfOwnDescriptors();
3085 Handle<DescriptorArray> array(map->instance_descriptors());
3086 NeanderArray callbacks(descriptors);
3087 ASSERT(array->NumberOfSlackDescriptors() >= callbacks.length());
3088 nof = AppendUniqueCallbacks<DescriptorArrayAppender>(&callbacks, array, nof);
3053 map->SetNumberOfOwnDescriptors(nof); 3089 map->SetNumberOfOwnDescriptors(nof);
3054 } 3090 }
3055 3091
3056 3092
3093 int AccessorInfo::AppendUnique(Handle<Object> descriptors,
3094 Handle<FixedArray> array,
3095 int valid_descriptors) {
3096 NeanderArray callbacks(descriptors);
3097 ASSERT(array->length() >= callbacks.length() + valid_descriptors);
3098 return AppendUniqueCallbacks<FixedArrayAppender>(&callbacks,
3099 array,
3100 valid_descriptors);
3101 }
3102
3103
3057 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) { 3104 static bool ContainsMap(MapHandleList* maps, Handle<Map> map) {
3058 ASSERT(!map.is_null()); 3105 ASSERT(!map.is_null());
3059 for (int i = 0; i < maps->length(); ++i) { 3106 for (int i = 0; i < maps->length(); ++i) {
3060 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true; 3107 if (!maps->at(i).is_null() && maps->at(i).is_identical_to(map)) return true;
3061 } 3108 }
3062 return false; 3109 return false;
3063 } 3110 }
3064 3111
3065 3112
3066 template <class T> 3113 template <class T>
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3443 if (isolate->has_pending_exception()) return Failure::Exception(); 3490 if (isolate->has_pending_exception()) return Failure::Exception();
3444 3491
3445 if (result->IsUndefined()) { 3492 if (result->IsUndefined()) {
3446 *done = false; 3493 *done = false;
3447 return isolate->heap()->the_hole_value(); 3494 return isolate->heap()->the_hole_value();
3448 } 3495 }
3449 3496
3450 // Emulate [[GetProperty]] semantics for proxies. 3497 // Emulate [[GetProperty]] semantics for proxies.
3451 bool has_pending_exception; 3498 bool has_pending_exception;
3452 Handle<Object> argv[] = { result }; 3499 Handle<Object> argv[] = { result };
3453 Handle<Object> desc = 3500 Handle<Object> desc = Execution::Call(
3454 Execution::Call(isolate->to_complete_property_descriptor(), result, 3501 isolate, isolate->to_complete_property_descriptor(), result,
3455 ARRAY_SIZE(argv), argv, &has_pending_exception); 3502 ARRAY_SIZE(argv), argv, &has_pending_exception);
3456 if (has_pending_exception) return Failure::Exception(); 3503 if (has_pending_exception) return Failure::Exception();
3457 3504
3458 // [[GetProperty]] requires to check that all properties are configurable. 3505 // [[GetProperty]] requires to check that all properties are configurable.
3459 Handle<String> configurable_name = 3506 Handle<String> configurable_name =
3460 isolate->factory()->InternalizeOneByteString( 3507 isolate->factory()->InternalizeOneByteString(
3461 STATIC_ASCII_VECTOR("configurable_")); 3508 STATIC_ASCII_VECTOR("configurable_"));
3462 Handle<Object> configurable( 3509 Handle<Object> configurable(
3463 v8::internal::GetProperty(isolate, desc, configurable_name)); 3510 v8::internal::GetProperty(isolate, desc, configurable_name));
3464 ASSERT(!isolate->has_pending_exception()); 3511 ASSERT(!isolate->has_pending_exception());
3465 ASSERT(configurable->IsTrue() || configurable->IsFalse()); 3512 ASSERT(configurable->IsTrue() || configurable->IsFalse());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3568 3615
3569 Handle<Object> args[] = { name }; 3616 Handle<Object> args[] = { name };
3570 Handle<Object> result = CallTrap( 3617 Handle<Object> result = CallTrap(
3571 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args); 3618 "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args);
3572 if (isolate->has_pending_exception()) return NONE; 3619 if (isolate->has_pending_exception()) return NONE;
3573 3620
3574 if (result->IsUndefined()) return ABSENT; 3621 if (result->IsUndefined()) return ABSENT;
3575 3622
3576 bool has_pending_exception; 3623 bool has_pending_exception;
3577 Handle<Object> argv[] = { result }; 3624 Handle<Object> argv[] = { result };
3578 Handle<Object> desc = 3625 Handle<Object> desc = Execution::Call(
3579 Execution::Call(isolate->to_complete_property_descriptor(), result, 3626 isolate, isolate->to_complete_property_descriptor(), result,
3580 ARRAY_SIZE(argv), argv, &has_pending_exception); 3627 ARRAY_SIZE(argv), argv, &has_pending_exception);
3581 if (has_pending_exception) return NONE; 3628 if (has_pending_exception) return NONE;
3582 3629
3583 // Convert result to PropertyAttributes. 3630 // Convert result to PropertyAttributes.
3584 Handle<String> enum_n = isolate->factory()->InternalizeOneByteString( 3631 Handle<String> enum_n = isolate->factory()->InternalizeOneByteString(
3585 STATIC_ASCII_VECTOR("enumerable_")); 3632 STATIC_ASCII_VECTOR("enumerable_"));
3586 Handle<Object> enumerable(v8::internal::GetProperty(isolate, desc, enum_n)); 3633 Handle<Object> enumerable(v8::internal::GetProperty(isolate, desc, enum_n));
3587 if (isolate->has_pending_exception()) return NONE; 3634 if (isolate->has_pending_exception()) return NONE;
3588 Handle<String> conf_n = isolate->factory()->InternalizeOneByteString( 3635 Handle<String> conf_n = isolate->factory()->InternalizeOneByteString(
3589 STATIC_ASCII_VECTOR("configurable_")); 3636 STATIC_ASCII_VECTOR("configurable_"));
3590 Handle<Object> configurable(v8::internal::GetProperty(isolate, desc, conf_n)); 3637 Handle<Object> configurable(v8::internal::GetProperty(isolate, desc, conf_n));
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 Handle<Object> args[] = { handler, trap_name }; 3715 Handle<Object> args[] = { handler, trap_name };
3669 Handle<Object> error = isolate->factory()->NewTypeError( 3716 Handle<Object> error = isolate->factory()->NewTypeError(
3670 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args))); 3717 "handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
3671 isolate->Throw(*error); 3718 isolate->Throw(*error);
3672 return Handle<Object>(); 3719 return Handle<Object>();
3673 } 3720 }
3674 trap = Handle<Object>(derived); 3721 trap = Handle<Object>(derived);
3675 } 3722 }
3676 3723
3677 bool threw; 3724 bool threw;
3678 return Execution::Call(trap, handler, argc, argv, &threw); 3725 return Execution::Call(isolate, trap, handler, argc, argv, &threw);
3679 } 3726 }
3680 3727
3681 3728
3682 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { 3729 void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
3683 CALL_HEAP_FUNCTION_VOID( 3730 CALL_HEAP_FUNCTION_VOID(
3684 object->GetIsolate(), 3731 object->GetIsolate(),
3685 object->AllocateStorageForMap(*map)); 3732 object->AllocateStorageForMap(*map));
3686 } 3733 }
3687 3734
3688 3735
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
4060 // From this point on everything needs to be handlified. 4107 // From this point on everything needs to be handlified.
4061 HandleScope scope(isolate); 4108 HandleScope scope(isolate);
4062 Handle<JSObject> self(this); 4109 Handle<JSObject> self(this);
4063 Handle<Name> name(name_raw); 4110 Handle<Name> name(name_raw);
4064 Handle<Object> value(value_raw, isolate); 4111 Handle<Object> value(value_raw, isolate);
4065 4112
4066 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate); 4113 Handle<Object> old_value(isolate->heap()->the_hole_value(), isolate);
4067 PropertyAttributes old_attributes = ABSENT; 4114 PropertyAttributes old_attributes = ABSENT;
4068 bool is_observed = FLAG_harmony_observation && self->map()->is_observed(); 4115 bool is_observed = FLAG_harmony_observation && self->map()->is_observed();
4069 if (is_observed && lookup.IsProperty()) { 4116 if (is_observed && lookup.IsProperty()) {
4070 if (lookup.IsDataProperty()) old_value = Object::GetProperty(self, name); 4117 if (lookup.IsDataProperty()) old_value =
4118 Object::GetProperty(self, name);
4071 old_attributes = lookup.GetAttributes(); 4119 old_attributes = lookup.GetAttributes();
4072 } 4120 }
4073 4121
4074 // Check of IsReadOnly removed from here in clone. 4122 // Check of IsReadOnly removed from here in clone.
4075 MaybeObject* result = *value; 4123 MaybeObject* result = *value;
4076 switch (lookup.type()) { 4124 switch (lookup.type()) {
4077 case NORMAL: 4125 case NORMAL:
4078 result = self->ReplaceSlowProperty(*name, *value, attributes); 4126 result = self->ReplaceSlowProperty(*name, *value, attributes);
4079 break; 4127 break;
4080 case FIELD: 4128 case FIELD:
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
5086 return DeleteElement(Handle<JSObject>::cast(proto), index, mode); 5134 return DeleteElement(Handle<JSObject>::cast(proto), index, mode);
5087 } 5135 }
5088 5136
5089 Handle<Object> old_value; 5137 Handle<Object> old_value;
5090 bool should_enqueue_change_record = false; 5138 bool should_enqueue_change_record = false;
5091 if (FLAG_harmony_observation && object->map()->is_observed()) { 5139 if (FLAG_harmony_observation && object->map()->is_observed()) {
5092 should_enqueue_change_record = object->HasLocalElement(index); 5140 should_enqueue_change_record = object->HasLocalElement(index);
5093 if (should_enqueue_change_record) { 5141 if (should_enqueue_change_record) {
5094 old_value = object->GetLocalElementAccessorPair(index) != NULL 5142 old_value = object->GetLocalElementAccessorPair(index) != NULL
5095 ? Handle<Object>::cast(factory->the_hole_value()) 5143 ? Handle<Object>::cast(factory->the_hole_value())
5096 : Object::GetElement(object, index); 5144 : Object::GetElement(isolate, object, index);
5097 } 5145 }
5098 } 5146 }
5099 5147
5100 // Skip interceptor if forcing deletion. 5148 // Skip interceptor if forcing deletion.
5101 Handle<Object> result; 5149 Handle<Object> result;
5102 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) { 5150 if (object->HasIndexedInterceptor() && mode != FORCE_DELETION) {
5103 result = DeleteElementWithInterceptor(object, index); 5151 result = DeleteElementWithInterceptor(object, index);
5104 } else { 5152 } else {
5105 result = AccessorDelete(object, index, mode); 5153 result = AccessorDelete(object, index, mode);
5106 } 5154 }
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
6122 uint32_t index = 0; 6170 uint32_t index = 0;
6123 bool is_element = name->AsArrayIndex(&index); 6171 bool is_element = name->AsArrayIndex(&index);
6124 6172
6125 Handle<Object> old_value = isolate->factory()->the_hole_value(); 6173 Handle<Object> old_value = isolate->factory()->the_hole_value();
6126 bool is_observed = FLAG_harmony_observation && object->map()->is_observed(); 6174 bool is_observed = FLAG_harmony_observation && object->map()->is_observed();
6127 bool preexists = false; 6175 bool preexists = false;
6128 if (is_observed) { 6176 if (is_observed) {
6129 if (is_element) { 6177 if (is_element) {
6130 preexists = object->HasLocalElement(index); 6178 preexists = object->HasLocalElement(index);
6131 if (preexists && object->GetLocalElementAccessorPair(index) == NULL) { 6179 if (preexists && object->GetLocalElementAccessorPair(index) == NULL) {
6132 old_value = Object::GetElement(object, index); 6180 old_value = Object::GetElement(isolate, object, index);
6133 } 6181 }
6134 } else { 6182 } else {
6135 LookupResult lookup(isolate); 6183 LookupResult lookup(isolate);
6136 object->LocalLookup(*name, &lookup, true); 6184 object->LocalLookup(*name, &lookup, true);
6137 preexists = lookup.IsProperty(); 6185 preexists = lookup.IsProperty();
6138 if (preexists && lookup.IsDataProperty()) { 6186 if (preexists && lookup.IsDataProperty()) {
6139 old_value = Object::GetProperty(object, name); 6187 old_value = Object::GetProperty(object, name);
6140 } 6188 }
6141 } 6189 }
6142 } 6190 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
6534 int old_size = descriptors->number_of_descriptors(); 6582 int old_size = descriptors->number_of_descriptors();
6535 6583
6536 DescriptorArray* new_descriptors; 6584 DescriptorArray* new_descriptors;
6537 6585
6538 if (descriptors->NumberOfSlackDescriptors() > 0) { 6586 if (descriptors->NumberOfSlackDescriptors() > 0) {
6539 new_descriptors = descriptors; 6587 new_descriptors = descriptors;
6540 new_descriptors->Append(descriptor); 6588 new_descriptors->Append(descriptor);
6541 } else { 6589 } else {
6542 // Descriptor arrays grow by 50%. 6590 // Descriptor arrays grow by 50%.
6543 MaybeObject* maybe_descriptors = DescriptorArray::Allocate( 6591 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(
6544 old_size, old_size < 4 ? 1 : old_size / 2); 6592 GetIsolate(), old_size, old_size < 4 ? 1 : old_size / 2);
6545 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 6593 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
6546 6594
6547 DescriptorArray::WhitenessWitness witness(new_descriptors); 6595 DescriptorArray::WhitenessWitness witness(new_descriptors);
6548 6596
6549 // Copy the descriptors, inserting a descriptor. 6597 // Copy the descriptors, inserting a descriptor.
6550 for (int i = 0; i < old_size; ++i) { 6598 for (int i = 0; i < old_size; ++i) {
6551 new_descriptors->CopyFrom(i, descriptors, i, witness); 6599 new_descriptors->CopyFrom(i, descriptors, i, witness);
6552 } 6600 }
6553 6601
6554 new_descriptors->Append(descriptor, witness); 6602 new_descriptors->Append(descriptor, witness);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
6784 int old_size = NumberOfOwnDescriptors(); 6832 int old_size = NumberOfOwnDescriptors();
6785 int new_size = old_size + 1; 6833 int new_size = old_size + 1;
6786 6834
6787 if (flag == INSERT_TRANSITION && 6835 if (flag == INSERT_TRANSITION &&
6788 owns_descriptors() && 6836 owns_descriptors() &&
6789 CanHaveMoreTransitions()) { 6837 CanHaveMoreTransitions()) {
6790 return ShareDescriptor(descriptors, descriptor); 6838 return ShareDescriptor(descriptors, descriptor);
6791 } 6839 }
6792 6840
6793 DescriptorArray* new_descriptors; 6841 DescriptorArray* new_descriptors;
6794 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(old_size, 1); 6842 MaybeObject* maybe_descriptors =
6843 DescriptorArray::Allocate(GetIsolate(), old_size, 1);
6795 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 6844 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
6796 6845
6797 DescriptorArray::WhitenessWitness witness(new_descriptors); 6846 DescriptorArray::WhitenessWitness witness(new_descriptors);
6798 6847
6799 // Copy the descriptors, inserting a descriptor. 6848 // Copy the descriptors, inserting a descriptor.
6800 for (int i = 0; i < old_size; ++i) { 6849 for (int i = 0; i < old_size; ++i) {
6801 new_descriptors->CopyFrom(i, descriptors, i, witness); 6850 new_descriptors->CopyFrom(i, descriptors, i, witness);
6802 } 6851 }
6803 6852
6804 if (old_size != descriptors->number_of_descriptors()) { 6853 if (old_size != descriptors->number_of_descriptors()) {
(...skipping 26 matching lines...) Expand all
6831 } 6880 }
6832 6881
6833 6882
6834 MaybeObject* DescriptorArray::CopyUpToAddAttributes( 6883 MaybeObject* DescriptorArray::CopyUpToAddAttributes(
6835 int enumeration_index, PropertyAttributes attributes) { 6884 int enumeration_index, PropertyAttributes attributes) {
6836 if (enumeration_index == 0) return GetHeap()->empty_descriptor_array(); 6885 if (enumeration_index == 0) return GetHeap()->empty_descriptor_array();
6837 6886
6838 int size = enumeration_index; 6887 int size = enumeration_index;
6839 6888
6840 DescriptorArray* descriptors; 6889 DescriptorArray* descriptors;
6841 MaybeObject* maybe_descriptors = Allocate(size); 6890 MaybeObject* maybe_descriptors = Allocate(GetIsolate(), size);
6842 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors; 6891 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors;
6843 DescriptorArray::WhitenessWitness witness(descriptors); 6892 DescriptorArray::WhitenessWitness witness(descriptors);
6844 6893
6845 if (attributes != NONE) { 6894 if (attributes != NONE) {
6846 for (int i = 0; i < size; ++i) { 6895 for (int i = 0; i < size; ++i) {
6847 Object* value = GetValue(i); 6896 Object* value = GetValue(i);
6848 PropertyDetails details = GetDetails(i); 6897 PropertyDetails details = GetDetails(i);
6849 int mask = DONT_DELETE | DONT_ENUM; 6898 int mask = DONT_DELETE | DONT_ENUM;
6850 // READ_ONLY is an invalid attribute for JS setters/getters. 6899 // READ_ONLY is an invalid attribute for JS setters/getters.
6851 if (details.type() != CALLBACKS || !value->IsAccessorPair()) { 6900 if (details.type() != CALLBACKS || !value->IsAccessorPair()) {
(...skipping 26 matching lines...) Expand all
6878 6927
6879 Name* key = descriptor->GetKey(); 6928 Name* key = descriptor->GetKey();
6880 ASSERT(key == descriptors->GetKey(insertion_index)); 6929 ASSERT(key == descriptors->GetKey(insertion_index));
6881 6930
6882 int new_size = NumberOfOwnDescriptors(); 6931 int new_size = NumberOfOwnDescriptors();
6883 ASSERT(0 <= insertion_index && insertion_index < new_size); 6932 ASSERT(0 <= insertion_index && insertion_index < new_size);
6884 6933
6885 ASSERT_LT(insertion_index, new_size); 6934 ASSERT_LT(insertion_index, new_size);
6886 6935
6887 DescriptorArray* new_descriptors; 6936 DescriptorArray* new_descriptors;
6888 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(new_size); 6937 MaybeObject* maybe_descriptors =
6938 DescriptorArray::Allocate(GetIsolate(), new_size);
6889 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; 6939 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
6890 DescriptorArray::WhitenessWitness witness(new_descriptors); 6940 DescriptorArray::WhitenessWitness witness(new_descriptors);
6891 6941
6892 for (int i = 0; i < new_size; ++i) { 6942 for (int i = 0; i < new_size; ++i) {
6893 if (i == insertion_index) { 6943 if (i == insertion_index) {
6894 new_descriptors->Set(i, descriptor, witness); 6944 new_descriptors->Set(i, descriptor, witness);
6895 } else { 6945 } else {
6896 new_descriptors->CopyFrom(i, descriptors, i, witness); 6946 new_descriptors->CopyFrom(i, descriptors, i, witness);
6897 } 6947 }
6898 } 6948 }
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
7668 bool FixedArray::IsEqualTo(FixedArray* other) { 7718 bool FixedArray::IsEqualTo(FixedArray* other) {
7669 if (length() != other->length()) return false; 7719 if (length() != other->length()) return false;
7670 for (int i = 0 ; i < length(); ++i) { 7720 for (int i = 0 ; i < length(); ++i) {
7671 if (get(i) != other->get(i)) return false; 7721 if (get(i) != other->get(i)) return false;
7672 } 7722 }
7673 return true; 7723 return true;
7674 } 7724 }
7675 #endif 7725 #endif
7676 7726
7677 7727
7678 MaybeObject* DescriptorArray::Allocate(int number_of_descriptors, int slack) { 7728 MaybeObject* DescriptorArray::Allocate(Isolate* isolate,
7679 Heap* heap = Isolate::Current()->heap(); 7729 int number_of_descriptors,
7730 int slack) {
7731 Heap* heap = isolate->heap();
7680 // Do not use DescriptorArray::cast on incomplete object. 7732 // Do not use DescriptorArray::cast on incomplete object.
7681 int size = number_of_descriptors + slack; 7733 int size = number_of_descriptors + slack;
7682 if (size == 0) return heap->empty_descriptor_array(); 7734 if (size == 0) return heap->empty_descriptor_array();
7683 FixedArray* result; 7735 FixedArray* result;
7684 // Allocate the array of keys. 7736 // Allocate the array of keys.
7685 MaybeObject* maybe_array = heap->AllocateFixedArray(LengthFor(size)); 7737 MaybeObject* maybe_array = heap->AllocateFixedArray(LengthFor(size));
7686 if (!maybe_array->To(&result)) return maybe_array; 7738 if (!maybe_array->To(&result)) return maybe_array;
7687 7739
7688 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors)); 7740 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors));
7689 result->set(kEnumCacheIndex, Smi::FromInt(0)); 7741 result->set(kEnumCacheIndex, Smi::FromInt(0));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
7737 int modify_index, 7789 int modify_index,
7738 StoreMode store_mode, 7790 StoreMode store_mode,
7739 DescriptorArray* other) { 7791 DescriptorArray* other) {
7740 ASSERT(verbatim <= valid); 7792 ASSERT(verbatim <= valid);
7741 ASSERT(valid <= new_size); 7793 ASSERT(valid <= new_size);
7742 7794
7743 DescriptorArray* result; 7795 DescriptorArray* result;
7744 // Allocate a new descriptor array large enough to hold the required 7796 // Allocate a new descriptor array large enough to hold the required
7745 // descriptors, with minimally the exact same size as this descriptor array. 7797 // descriptors, with minimally the exact same size as this descriptor array.
7746 MaybeObject* maybe_descriptors = DescriptorArray::Allocate( 7798 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(
7747 new_size, Max(new_size, other->number_of_descriptors()) - new_size); 7799 GetIsolate(), new_size,
7800 Max(new_size, other->number_of_descriptors()) - new_size);
7748 if (!maybe_descriptors->To(&result)) return maybe_descriptors; 7801 if (!maybe_descriptors->To(&result)) return maybe_descriptors;
7749 ASSERT(result->length() > length() || 7802 ASSERT(result->length() > length() ||
7750 result->NumberOfSlackDescriptors() > 0 || 7803 result->NumberOfSlackDescriptors() > 0 ||
7751 result->number_of_descriptors() == other->number_of_descriptors()); 7804 result->number_of_descriptors() == other->number_of_descriptors());
7752 ASSERT(result->number_of_descriptors() == new_size); 7805 ASSERT(result->number_of_descriptors() == new_size);
7753 7806
7754 DescriptorArray::WhitenessWitness witness(result); 7807 DescriptorArray::WhitenessWitness witness(result);
7755 7808
7756 int descriptor; 7809 int descriptor;
7757 7810
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
7953 8006
7954 8007
7955 bool Name::IsCacheable(Isolate* isolate) { 8008 bool Name::IsCacheable(Isolate* isolate) {
7956 return IsSymbol() || 8009 return IsSymbol() ||
7957 IsIdentifier(isolate->unicode_cache(), this) || 8010 IsIdentifier(isolate->unicode_cache(), this) ||
7958 this == isolate->heap()->hidden_string(); 8011 this == isolate->heap()->hidden_string();
7959 } 8012 }
7960 8013
7961 8014
7962 bool String::LooksValid() { 8015 bool String::LooksValid() {
7963 if (!Isolate::Current()->heap()->Contains(this)) return false; 8016 if (!GetIsolate()->heap()->Contains(this)) return false;
7964 return true; 8017 return true;
7965 } 8018 }
7966 8019
7967 8020
7968 String::FlatContent String::GetFlatContent() { 8021 String::FlatContent String::GetFlatContent() {
7969 ASSERT(!AllowHeapAllocation::IsAllowed()); 8022 ASSERT(!AllowHeapAllocation::IsAllowed());
7970 int length = this->length(); 8023 int length = this->length();
7971 StringShape shape(this); 8024 StringShape shape(this);
7972 String* string = this; 8025 String* string = this;
7973 int offset = 0; 8026 int offset = 0;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
8113 return SmartArrayPointer<uc16>(result); 8166 return SmartArrayPointer<uc16>(result);
8114 } 8167 }
8115 8168
8116 8169
8117 const uc16* SeqTwoByteString::SeqTwoByteStringGetData(unsigned start) { 8170 const uc16* SeqTwoByteString::SeqTwoByteStringGetData(unsigned start) {
8118 return reinterpret_cast<uc16*>( 8171 return reinterpret_cast<uc16*>(
8119 reinterpret_cast<char*>(this) - kHeapObjectTag + kHeaderSize) + start; 8172 reinterpret_cast<char*>(this) - kHeapObjectTag + kHeaderSize) + start;
8120 } 8173 }
8121 8174
8122 8175
8123 void Relocatable::PostGarbageCollectionProcessing() { 8176 void Relocatable::PostGarbageCollectionProcessing(Isolate* isolate) {
8124 Isolate* isolate = Isolate::Current();
8125 Relocatable* current = isolate->relocatable_top(); 8177 Relocatable* current = isolate->relocatable_top();
8126 while (current != NULL) { 8178 while (current != NULL) {
8127 current->PostGarbageCollection(); 8179 current->PostGarbageCollection();
8128 current = current->prev_; 8180 current = current->prev_;
8129 } 8181 }
8130 } 8182 }
8131 8183
8132 8184
8133 // Reserve space for statics needing saving and restoring. 8185 // Reserve space for statics needing saving and restoring.
8134 int Relocatable::ArchiveSpacePerThread() { 8186 int Relocatable::ArchiveSpacePerThread() {
8135 return sizeof(Isolate::Current()->relocatable_top()); 8187 return sizeof(Relocatable*); // NOLINT
8136 } 8188 }
8137 8189
8138 8190
8139 // Archive statics that are thread local. 8191 // Archive statics that are thread local.
8140 char* Relocatable::ArchiveState(Isolate* isolate, char* to) { 8192 char* Relocatable::ArchiveState(Isolate* isolate, char* to) {
8141 *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top(); 8193 *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top();
8142 isolate->set_relocatable_top(NULL); 8194 isolate->set_relocatable_top(NULL);
8143 return to + ArchiveSpacePerThread(); 8195 return to + ArchiveSpacePerThread();
8144 } 8196 }
8145 8197
8146 8198
8147 // Restore statics that are thread local. 8199 // Restore statics that are thread local.
8148 char* Relocatable::RestoreState(Isolate* isolate, char* from) { 8200 char* Relocatable::RestoreState(Isolate* isolate, char* from) {
8149 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from)); 8201 isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
8150 return from + ArchiveSpacePerThread(); 8202 return from + ArchiveSpacePerThread();
8151 } 8203 }
8152 8204
8153 8205
8154 char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) { 8206 char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) {
8155 Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage); 8207 Relocatable* top = *reinterpret_cast<Relocatable**>(thread_storage);
8156 Iterate(v, top); 8208 Iterate(v, top);
8157 return thread_storage + ArchiveSpacePerThread(); 8209 return thread_storage + ArchiveSpacePerThread();
8158 } 8210 }
8159 8211
8160 8212
8161 void Relocatable::Iterate(ObjectVisitor* v) { 8213 void Relocatable::Iterate(Isolate* isolate, ObjectVisitor* v) {
8162 Isolate* isolate = Isolate::Current();
8163 Iterate(v, isolate->relocatable_top()); 8214 Iterate(v, isolate->relocatable_top());
8164 } 8215 }
8165 8216
8166 8217
8167 void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) { 8218 void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) {
8168 Relocatable* current = top; 8219 Relocatable* current = top;
8169 while (current != NULL) { 8220 while (current != NULL) {
8170 current->IterateInstance(v); 8221 current->IterateInstance(v);
8171 current = current->prev_; 8222 current = current->prev_;
8172 } 8223 }
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
9266 // No write barrier required, since the builtin is part of the root set. 9317 // No write barrier required, since the builtin is part of the root set.
9267 } 9318 }
9268 9319
9269 9320
9270 static bool CompileLazyHelper(CompilationInfo* info, 9321 static bool CompileLazyHelper(CompilationInfo* info,
9271 ClearExceptionFlag flag) { 9322 ClearExceptionFlag flag) {
9272 // Compile the source information to a code object. 9323 // Compile the source information to a code object.
9273 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled()); 9324 ASSERT(info->IsOptimizing() || !info->shared_info()->is_compiled());
9274 ASSERT(!info->isolate()->has_pending_exception()); 9325 ASSERT(!info->isolate()->has_pending_exception());
9275 bool result = Compiler::CompileLazy(info); 9326 bool result = Compiler::CompileLazy(info);
9276 ASSERT(result != Isolate::Current()->has_pending_exception()); 9327 ASSERT(result != info->isolate()->has_pending_exception());
9277 if (!result && flag == CLEAR_EXCEPTION) { 9328 if (!result && flag == CLEAR_EXCEPTION) {
9278 info->isolate()->clear_pending_exception(); 9329 info->isolate()->clear_pending_exception();
9279 } 9330 }
9280 return result; 9331 return result;
9281 } 9332 }
9282 9333
9283 9334
9284 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared, 9335 bool SharedFunctionInfo::CompileLazy(Handle<SharedFunctionInfo> shared,
9285 ClearExceptionFlag flag) { 9336 ClearExceptionFlag flag) {
9286 ASSERT(shared->allows_lazy_compilation_without_context()); 9337 ASSERT(shared->allows_lazy_compilation_without_context());
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
9656 return true; 9707 return true;
9657 } 9708 }
9658 if (filter[filter.length() - 1] == '*' && 9709 if (filter[filter.length() - 1] == '*' &&
9659 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) { 9710 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
9660 return true; 9711 return true;
9661 } 9712 }
9662 return false; 9713 return false;
9663 } 9714 }
9664 9715
9665 9716
9666 MaybeObject* Oddball::Initialize(const char* to_string, 9717 MaybeObject* Oddball::Initialize(Heap* heap,
9718 const char* to_string,
9667 Object* to_number, 9719 Object* to_number,
9668 byte kind) { 9720 byte kind) {
9669 String* internalized_to_string; 9721 String* internalized_to_string;
9670 { MaybeObject* maybe_string = 9722 { MaybeObject* maybe_string =
9671 Isolate::Current()->heap()->InternalizeUtf8String( 9723 heap->InternalizeUtf8String(
9672 CStrVector(to_string)); 9724 CStrVector(to_string));
9673 if (!maybe_string->To(&internalized_to_string)) return maybe_string; 9725 if (!maybe_string->To(&internalized_to_string)) return maybe_string;
9674 } 9726 }
9675 set_to_string(internalized_to_string); 9727 set_to_string(internalized_to_string);
9676 set_to_number(to_number); 9728 set_to_number(to_number);
9677 set_kind(kind); 9729 set_kind(kind);
9678 return this; 9730 return this;
9679 } 9731 }
9680 9732
9681 9733
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
9795 9847
9796 void SharedFunctionInfo::DisableOptimization(BailoutReason reason) { 9848 void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
9797 // Disable optimization for the shared function info and mark the 9849 // Disable optimization for the shared function info and mark the
9798 // code as non-optimizable. The marker on the shared function info 9850 // code as non-optimizable. The marker on the shared function info
9799 // is there because we flush non-optimized code thereby loosing the 9851 // is there because we flush non-optimized code thereby loosing the
9800 // non-optimizable information for the code. When the code is 9852 // non-optimizable information for the code. When the code is
9801 // regenerated and set on the shared function info it is marked as 9853 // regenerated and set on the shared function info it is marked as
9802 // non-optimizable if optimization is disabled for the shared 9854 // non-optimizable if optimization is disabled for the shared
9803 // function info. 9855 // function info.
9804 set_optimization_disabled(true); 9856 set_optimization_disabled(true);
9857 set_bailout_reason(reason);
9805 // Code should be the lazy compilation stub or else unoptimized. If the 9858 // Code should be the lazy compilation stub or else unoptimized. If the
9806 // latter, disable optimization for the code too. 9859 // latter, disable optimization for the code too.
9807 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN); 9860 ASSERT(code()->kind() == Code::FUNCTION || code()->kind() == Code::BUILTIN);
9808 if (code()->kind() == Code::FUNCTION) { 9861 if (code()->kind() == Code::FUNCTION) {
9809 code()->set_optimizable(false); 9862 code()->set_optimizable(false);
9810 } 9863 }
9864 PROFILE(Isolate::Current(),
9865 LogExistingFunction(Handle<SharedFunctionInfo>(this),
9866 Handle<Code>(code())));
9811 if (FLAG_trace_opt) { 9867 if (FLAG_trace_opt) {
9812 PrintF("[disabled optimization for "); 9868 PrintF("[disabled optimization for ");
9813 ShortPrint(); 9869 ShortPrint();
9814 PrintF(", reason: %s]\n", GetBailoutReason(reason)); 9870 PrintF(", reason: %s]\n", GetBailoutReason(reason));
9815 } 9871 }
9816 } 9872 }
9817 9873
9818 9874
9819 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) { 9875 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) {
9820 ASSERT(!id.IsNone()); 9876 ASSERT(!id.IsNone());
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
10298 10354
10299 void Code::ClearInlineCaches() { 10355 void Code::ClearInlineCaches() {
10300 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | 10356 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
10301 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | 10357 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
10302 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | 10358 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) |
10303 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); 10359 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT);
10304 for (RelocIterator it(this, mask); !it.done(); it.next()) { 10360 for (RelocIterator it(this, mask); !it.done(); it.next()) {
10305 RelocInfo* info = it.rinfo(); 10361 RelocInfo* info = it.rinfo();
10306 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); 10362 Code* target(Code::GetCodeFromTargetAddress(info->target_address()));
10307 if (target->is_inline_cache_stub()) { 10363 if (target->is_inline_cache_stub()) {
10308 IC::Clear(info->pc()); 10364 IC::Clear(this->GetIsolate(), info->pc());
10309 } 10365 }
10310 } 10366 }
10311 } 10367 }
10312 10368
10313 10369
10314 void Code::ClearTypeFeedbackCells(Heap* heap) { 10370 void Code::ClearTypeFeedbackCells(Heap* heap) {
10315 if (kind() != FUNCTION) return; 10371 if (kind() != FUNCTION) return;
10316 Object* raw_info = type_feedback_info(); 10372 Object* raw_info = type_feedback_info();
10317 if (raw_info->IsTypeFeedbackInfo()) { 10373 if (raw_info->IsTypeFeedbackInfo()) {
10318 TypeFeedbackCells* type_feedback_cells = 10374 TypeFeedbackCells* type_feedback_cells =
10319 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells(); 10375 TypeFeedbackInfo::cast(raw_info)->type_feedback_cells();
10320 for (int i = 0; i < type_feedback_cells->CellCount(); i++) { 10376 for (int i = 0; i < type_feedback_cells->CellCount(); i++) {
10321 Cell* cell = type_feedback_cells->GetCell(i); 10377 Cell* cell = type_feedback_cells->GetCell(i);
10322 // Don't clear AllocationSites 10378 // Don't clear AllocationSites
10323 Object* value = cell->value(); 10379 Object* value = cell->value();
10324 if (value == NULL || !value->IsAllocationSite()) { 10380 if (value == NULL || !value->IsAllocationSite()) {
10325 cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap)); 10381 cell->set_value(TypeFeedbackCells::RawUninitializedSentinel(heap));
10326 } 10382 }
10327 } 10383 }
10328 } 10384 }
10329 } 10385 }
10330 10386
10331 10387
10388 BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) {
10389 DisallowHeapAllocation no_gc;
10390 ASSERT(kind() == FUNCTION);
10391 for (FullCodeGenerator::BackEdgeTableIterator it(this, &no_gc);
10392 !it.Done();
10393 it.Next()) {
10394 if (it.pc_offset() == pc_offset) return it.ast_id();
10395 }
10396 return BailoutId::None();
10397 }
10398
10399
10332 bool Code::allowed_in_shared_map_code_cache() { 10400 bool Code::allowed_in_shared_map_code_cache() {
10333 return is_keyed_load_stub() || is_keyed_store_stub() || 10401 return is_keyed_load_stub() || is_keyed_store_stub() ||
10334 (is_compare_ic_stub() && 10402 (is_compare_ic_stub() &&
10335 ICCompareStub::CompareState(stub_info()) == CompareIC::KNOWN_OBJECT); 10403 ICCompareStub::CompareState(stub_info()) == CompareIC::KNOWN_OBJECT);
10336 } 10404 }
10337 10405
10338 10406
10339 void Code::MakeCodeAgeSequenceYoung(byte* sequence) { 10407 void Code::MakeCodeAgeSequenceYoung(byte* sequence) {
10340 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); 10408 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY);
10341 } 10409 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
10382 } 10450 }
10383 Age age; 10451 Age age;
10384 MarkingParity parity; 10452 MarkingParity parity;
10385 GetCodeAgeAndParity(sequence, &age, &parity); 10453 GetCodeAgeAndParity(sequence, &age, &parity);
10386 return age; 10454 return age;
10387 } 10455 }
10388 10456
10389 10457
10390 void Code::GetCodeAgeAndParity(Code* code, Age* age, 10458 void Code::GetCodeAgeAndParity(Code* code, Age* age,
10391 MarkingParity* parity) { 10459 MarkingParity* parity) {
10392 Isolate* isolate = Isolate::Current(); 10460 Isolate* isolate = code->GetIsolate();
10393 Builtins* builtins = isolate->builtins(); 10461 Builtins* builtins = isolate->builtins();
10394 Code* stub = NULL; 10462 Code* stub = NULL;
10395 #define HANDLE_CODE_AGE(AGE) \ 10463 #define HANDLE_CODE_AGE(AGE) \
10396 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \ 10464 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \
10397 if (code == stub) { \ 10465 if (code == stub) { \
10398 *age = k##AGE##CodeAge; \ 10466 *age = k##AGE##CodeAge; \
10399 *parity = EVEN_MARKING_PARITY; \ 10467 *parity = EVEN_MARKING_PARITY; \
10400 return; \ 10468 return; \
10401 } \ 10469 } \
10402 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ 10470 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
10782 PrintF(out, " argc: %d", entry.argument_count()); 10850 PrintF(out, " argc: %d", entry.argument_count());
10783 } 10851 }
10784 PrintF(out, "\n"); 10852 PrintF(out, "\n");
10785 } 10853 }
10786 PrintF(out, "\n"); 10854 PrintF(out, "\n");
10787 } else if (kind() == FUNCTION) { 10855 } else if (kind() == FUNCTION) {
10788 unsigned offset = back_edge_table_offset(); 10856 unsigned offset = back_edge_table_offset();
10789 // If there is no back edge table, the "table start" will be at or after 10857 // If there is no back edge table, the "table start" will be at or after
10790 // (due to alignment) the end of the instruction stream. 10858 // (due to alignment) the end of the instruction stream.
10791 if (static_cast<int>(offset) < instruction_size()) { 10859 if (static_cast<int>(offset) < instruction_size()) {
10792 FullCodeGenerator::BackEdgeTableIterator back_edges(this); 10860 DisallowHeapAllocation no_gc;
10861 FullCodeGenerator::BackEdgeTableIterator back_edges(this, &no_gc);
10793 10862
10794 PrintF(out, "Back edges (size = %u)\n", back_edges.table_length()); 10863 PrintF(out, "Back edges (size = %u)\n", back_edges.table_length());
10795 PrintF(out, "ast_id pc_offset loop_depth\n"); 10864 PrintF(out, "ast_id pc_offset loop_depth\n");
10796 10865
10797 for ( ; !back_edges.Done(); back_edges.Next()) { 10866 for ( ; !back_edges.Done(); back_edges.Next()) {
10798 PrintF(out, "%6d %9u %10u\n", back_edges.ast_id().ToInt(), 10867 PrintF(out, "%6d %9u %10u\n", back_edges.ast_id().ToInt(),
10799 back_edges.pc_offset(), 10868 back_edges.pc_offset(),
10800 back_edges.loop_depth()); 10869 back_edges.loop_depth());
10801 } 10870 }
10802 10871
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
10958 // no further old values need be collected. 11027 // no further old values need be collected.
10959 static bool GetOldValue(Isolate* isolate, 11028 static bool GetOldValue(Isolate* isolate,
10960 Handle<JSObject> object, 11029 Handle<JSObject> object,
10961 uint32_t index, 11030 uint32_t index,
10962 List<Handle<Object> >* old_values, 11031 List<Handle<Object> >* old_values,
10963 List<uint32_t>* indices) { 11032 List<uint32_t>* indices) {
10964 PropertyAttributes attributes = object->GetLocalElementAttribute(index); 11033 PropertyAttributes attributes = object->GetLocalElementAttribute(index);
10965 ASSERT(attributes != ABSENT); 11034 ASSERT(attributes != ABSENT);
10966 if (attributes == DONT_DELETE) return false; 11035 if (attributes == DONT_DELETE) return false;
10967 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL 11036 old_values->Add(object->GetLocalElementAccessorPair(index) == NULL
10968 ? Object::GetElement(object, index) 11037 ? Object::GetElement(isolate, object, index)
10969 : Handle<Object>::cast(isolate->factory()->the_hole_value())); 11038 : Handle<Object>::cast(isolate->factory()->the_hole_value()));
10970 indices->Add(index); 11039 indices->Add(index);
10971 return true; 11040 return true;
10972 } 11041 }
10973 11042
10974 static void EnqueueSpliceRecord(Handle<JSArray> object, 11043 static void EnqueueSpliceRecord(Handle<JSArray> object,
10975 uint32_t index, 11044 uint32_t index,
10976 Handle<JSArray> deleted, 11045 Handle<JSArray> deleted,
10977 uint32_t add_count) { 11046 uint32_t add_count) {
10978 Isolate* isolate = object->GetIsolate(); 11047 Isolate* isolate = object->GetIsolate();
10979 HandleScope scope(isolate); 11048 HandleScope scope(isolate);
10980 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); 11049 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index);
10981 Handle<Object> add_count_object = 11050 Handle<Object> add_count_object =
10982 isolate->factory()->NewNumberFromUint(add_count); 11051 isolate->factory()->NewNumberFromUint(add_count);
10983 11052
10984 Handle<Object> args[] = 11053 Handle<Object> args[] =
10985 { object, index_object, deleted, add_count_object }; 11054 { object, index_object, deleted, add_count_object };
10986 11055
10987 bool threw; 11056 bool threw;
10988 Execution::Call(Handle<JSFunction>(isolate->observers_enqueue_splice()), 11057 Execution::Call(isolate,
11058 Handle<JSFunction>(isolate->observers_enqueue_splice()),
10989 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, 11059 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
10990 &threw); 11060 &threw);
10991 ASSERT(!threw); 11061 ASSERT(!threw);
10992 } 11062 }
10993 11063
10994 11064
10995 static void BeginPerformSplice(Handle<JSArray> object) { 11065 static void BeginPerformSplice(Handle<JSArray> object) {
10996 Isolate* isolate = object->GetIsolate(); 11066 Isolate* isolate = object->GetIsolate();
10997 HandleScope scope(isolate); 11067 HandleScope scope(isolate);
10998 Handle<Object> args[] = { object }; 11068 Handle<Object> args[] = { object };
10999 11069
11000 bool threw; 11070 bool threw;
11001 Execution::Call(Handle<JSFunction>(isolate->observers_begin_perform_splice()), 11071 Execution::Call(isolate,
11072 Handle<JSFunction>(isolate->observers_begin_perform_splice()),
11002 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, 11073 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
11003 &threw); 11074 &threw);
11004 ASSERT(!threw); 11075 ASSERT(!threw);
11005 } 11076 }
11006 11077
11007 11078
11008 static void EndPerformSplice(Handle<JSArray> object) { 11079 static void EndPerformSplice(Handle<JSArray> object) {
11009 Isolate* isolate = object->GetIsolate(); 11080 Isolate* isolate = object->GetIsolate();
11010 HandleScope scope(isolate); 11081 HandleScope scope(isolate);
11011 Handle<Object> args[] = { object }; 11082 Handle<Object> args[] = { object };
11012 11083
11013 bool threw; 11084 bool threw;
11014 Execution::Call(Handle<JSFunction>(isolate->observers_end_perform_splice()), 11085 Execution::Call(isolate,
11086 Handle<JSFunction>(isolate->observers_end_perform_splice()),
11015 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args, 11087 isolate->factory()->undefined_value(), ARRAY_SIZE(args), args,
11016 &threw); 11088 &threw);
11017 ASSERT(!threw); 11089 ASSERT(!threw);
11018 } 11090 }
11019 11091
11020 11092
11021 MaybeObject* JSArray::SetElementsLength(Object* len) { 11093 MaybeObject* JSArray::SetElementsLength(Object* len) {
11022 // We should never end in here with a pixel or external array. 11094 // We should never end in here with a pixel or external array.
11023 ASSERT(AllowsSetElementsLength()); 11095 ASSERT(AllowsSetElementsLength());
11024 if (!(FLAG_harmony_observation && map()->is_observed())) 11096 if (!(FLAG_harmony_observation && map()->is_observed()))
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
11343 Isolate* isolate, 11415 Isolate* isolate,
11344 DependentCode::DependencyGroup group) { 11416 DependentCode::DependencyGroup group) {
11345 ASSERT(AllowCodeDependencyChange::IsAllowed()); 11417 ASSERT(AllowCodeDependencyChange::IsAllowed());
11346 DisallowHeapAllocation no_allocation_scope; 11418 DisallowHeapAllocation no_allocation_scope;
11347 DependentCode::GroupStartIndexes starts(this); 11419 DependentCode::GroupStartIndexes starts(this);
11348 int start = starts.at(group); 11420 int start = starts.at(group);
11349 int end = starts.at(group + 1); 11421 int end = starts.at(group + 1);
11350 int code_entries = starts.number_of_entries(); 11422 int code_entries = starts.number_of_entries();
11351 if (start == end) return; 11423 if (start == end) return;
11352 11424
11353 // Collect all the code to deoptimize. 11425 // Mark all the code that needs to be deoptimized.
11354 Zone zone(isolate); 11426 bool marked = false;
11355 ZoneList<Code*> codes(end - start, &zone);
11356 for (int i = start; i < end; i++) { 11427 for (int i = start; i < end; i++) {
11357 if (is_code_at(i)) { 11428 if (is_code_at(i)) {
11358 Code* code = code_at(i); 11429 Code* code = code_at(i);
11359 if (!code->marked_for_deoptimization()) codes.Add(code, &zone); 11430 if (!code->marked_for_deoptimization()) {
11431 code->set_marked_for_deoptimization(true);
11432 marked = true;
11433 }
11360 } else { 11434 } else {
11361 CompilationInfo* info = compilation_info_at(i); 11435 CompilationInfo* info = compilation_info_at(i);
11362 info->AbortDueToDependencyChange(); 11436 info->AbortDueToDependencyChange();
11363 } 11437 }
11364 } 11438 }
11365 // Compact the array by moving all subsequent groups to fill in the new holes. 11439 // Compact the array by moving all subsequent groups to fill in the new holes.
11366 for (int src = end, dst = start; src < code_entries; src++, dst++) { 11440 for (int src = end, dst = start; src < code_entries; src++, dst++) {
11367 copy(src, dst); 11441 copy(src, dst);
11368 } 11442 }
11369 // Now the holes are at the end of the array, zap them for heap-verifier. 11443 // Now the holes are at the end of the array, zap them for heap-verifier.
11370 int removed = end - start; 11444 int removed = end - start;
11371 for (int i = code_entries - removed; i < code_entries; i++) { 11445 for (int i = code_entries - removed; i < code_entries; i++) {
11372 clear_at(i); 11446 clear_at(i);
11373 } 11447 }
11374 set_number_of_entries(group, 0); 11448 set_number_of_entries(group, 0);
11375 Deoptimizer::DeoptimizeCodeList(isolate, &codes); 11449
11450 if (marked) Deoptimizer::DeoptimizeMarkedCode(isolate);
11376 } 11451 }
11377 11452
11378 11453
11379 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object, 11454 Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
11380 Handle<Object> value, 11455 Handle<Object> value,
11381 bool skip_hidden_prototypes) { 11456 bool skip_hidden_prototypes) {
11382 #ifdef DEBUG 11457 #ifdef DEBUG
11383 int size = object->Size(); 11458 int size = object->Size();
11384 #endif 11459 #endif
11385 11460
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
12120 12195
12121 Handle<Object> JSObject::SetElement(Handle<JSObject> object, 12196 Handle<Object> JSObject::SetElement(Handle<JSObject> object,
12122 uint32_t index, 12197 uint32_t index,
12123 Handle<Object> value, 12198 Handle<Object> value,
12124 PropertyAttributes attr, 12199 PropertyAttributes attr,
12125 StrictModeFlag strict_mode, 12200 StrictModeFlag strict_mode,
12126 SetPropertyMode set_mode) { 12201 SetPropertyMode set_mode) {
12127 if (object->HasExternalArrayElements()) { 12202 if (object->HasExternalArrayElements()) {
12128 if (!value->IsNumber() && !value->IsUndefined()) { 12203 if (!value->IsNumber() && !value->IsUndefined()) {
12129 bool has_exception; 12204 bool has_exception;
12130 Handle<Object> number = Execution::ToNumber(value, &has_exception); 12205 Handle<Object> number =
12206 Execution::ToNumber(object->GetIsolate(), value, &has_exception);
12131 if (has_exception) return Handle<Object>(); 12207 if (has_exception) return Handle<Object>();
12132 value = number; 12208 value = number;
12133 } 12209 }
12134 } 12210 }
12135 CALL_HEAP_FUNCTION( 12211 CALL_HEAP_FUNCTION(
12136 object->GetIsolate(), 12212 object->GetIsolate(),
12137 object->SetElement(index, *value, attr, strict_mode, true, set_mode), 12213 object->SetElement(index, *value, attr, strict_mode, true, set_mode),
12138 Object); 12214 Object);
12139 } 12215 }
12140 12216
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
12197 // From here on, everything has to be handlified. 12273 // From here on, everything has to be handlified.
12198 Handle<JSObject> self(this); 12274 Handle<JSObject> self(this);
12199 Handle<Object> value(value_raw, isolate); 12275 Handle<Object> value(value_raw, isolate);
12200 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index); 12276 PropertyAttributes old_attributes = self->GetLocalElementAttribute(index);
12201 Handle<Object> old_value = isolate->factory()->the_hole_value(); 12277 Handle<Object> old_value = isolate->factory()->the_hole_value();
12202 Handle<Object> old_length_handle; 12278 Handle<Object> old_length_handle;
12203 Handle<Object> new_length_handle; 12279 Handle<Object> new_length_handle;
12204 12280
12205 if (old_attributes != ABSENT) { 12281 if (old_attributes != ABSENT) {
12206 if (self->GetLocalElementAccessorPair(index) == NULL) 12282 if (self->GetLocalElementAccessorPair(index) == NULL)
12207 old_value = Object::GetElement(self, index); 12283 old_value = Object::GetElement(isolate, self, index);
12208 } else if (self->IsJSArray()) { 12284 } else if (self->IsJSArray()) {
12209 // Store old array length in case adding an element grows the array. 12285 // Store old array length in case adding an element grows the array.
12210 old_length_handle = handle(Handle<JSArray>::cast(self)->length(), isolate); 12286 old_length_handle = handle(Handle<JSArray>::cast(self)->length(), isolate);
12211 } 12287 }
12212 12288
12213 // Check for lookup interceptor 12289 // Check for lookup interceptor
12214 MaybeObject* result = self->HasIndexedInterceptor() 12290 MaybeObject* result = self->HasIndexedInterceptor()
12215 ? self->SetElementWithInterceptor( 12291 ? self->SetElementWithInterceptor(
12216 index, *value, attributes, strict_mode, check_prototype, set_mode) 12292 index, *value, attributes, strict_mode, check_prototype, set_mode)
12217 : self->SetElementWithoutInterceptor( 12293 : self->SetElementWithoutInterceptor(
(...skipping 21 matching lines...) Expand all
12239 EndPerformSplice(Handle<JSArray>::cast(self)); 12315 EndPerformSplice(Handle<JSArray>::cast(self));
12240 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); 12316 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
12241 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted, 12317 EnqueueSpliceRecord(Handle<JSArray>::cast(self), old_length, deleted,
12242 new_length - old_length); 12318 new_length - old_length);
12243 } else { 12319 } else {
12244 EnqueueChangeRecord(self, "new", name, old_value); 12320 EnqueueChangeRecord(self, "new", name, old_value);
12245 } 12321 }
12246 } else if (old_value->IsTheHole()) { 12322 } else if (old_value->IsTheHole()) {
12247 EnqueueChangeRecord(self, "reconfigured", name, old_value); 12323 EnqueueChangeRecord(self, "reconfigured", name, old_value);
12248 } else { 12324 } else {
12249 Handle<Object> new_value = Object::GetElement(self, index); 12325 Handle<Object> new_value = Object::GetElement(isolate, self, index);
12250 bool value_changed = !old_value->SameValue(*new_value); 12326 bool value_changed = !old_value->SameValue(*new_value);
12251 if (old_attributes != new_attributes) { 12327 if (old_attributes != new_attributes) {
12252 if (!value_changed) old_value = isolate->factory()->the_hole_value(); 12328 if (!value_changed) old_value = isolate->factory()->the_hole_value();
12253 EnqueueChangeRecord(self, "reconfigured", name, old_value); 12329 EnqueueChangeRecord(self, "reconfigured", name, old_value);
12254 } else if (value_changed) { 12330 } else if (value_changed) {
12255 EnqueueChangeRecord(self, "updated", name, old_value); 12331 EnqueueChangeRecord(self, "updated", name, old_value);
12256 } 12332 }
12257 } 12333 }
12258 12334
12259 return *hresult; 12335 return *hresult;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
12567 ElementsAccessor* handler = holder_handle->GetElementsAccessor(); 12643 ElementsAccessor* handler = holder_handle->GetElementsAccessor();
12568 MaybeObject* raw_result = handler->Get(*this_handle, 12644 MaybeObject* raw_result = handler->Get(*this_handle,
12569 *holder_handle, 12645 *holder_handle,
12570 index); 12646 index);
12571 if (raw_result != heap->the_hole_value()) return raw_result; 12647 if (raw_result != heap->the_hole_value()) return raw_result;
12572 12648
12573 RETURN_IF_SCHEDULED_EXCEPTION(isolate); 12649 RETURN_IF_SCHEDULED_EXCEPTION(isolate);
12574 12650
12575 Object* pt = holder_handle->GetPrototype(); 12651 Object* pt = holder_handle->GetPrototype();
12576 if (pt == heap->null_value()) return heap->undefined_value(); 12652 if (pt == heap->null_value()) return heap->undefined_value();
12577 return pt->GetElementWithReceiver(*this_handle, index); 12653 return pt->GetElementWithReceiver(isolate, *this_handle, index);
12578 } 12654 }
12579 12655
12580 12656
12581 bool JSObject::HasDenseElements() { 12657 bool JSObject::HasDenseElements() {
12582 int capacity = 0; 12658 int capacity = 0;
12583 int used = 0; 12659 int used = 0;
12584 GetElementsCapacityAndUsage(&capacity, &used); 12660 GetElementsCapacityAndUsage(&capacity, &used);
12585 return (capacity == 0) || (used > (capacity / 2)); 12661 return (capacity == 0) || (used > (capacity / 2));
12586 } 12662 }
12587 12663
(...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after
15212 obj->set_map(new_map); 15288 obj->set_map(new_map);
15213 obj->set_properties(heap->empty_fixed_array()); 15289 obj->set_properties(heap->empty_fixed_array());
15214 // Check that it really works. 15290 // Check that it really works.
15215 ASSERT(obj->HasFastProperties()); 15291 ASSERT(obj->HasFastProperties());
15216 return obj; 15292 return obj;
15217 } 15293 }
15218 15294
15219 // Allocate the instance descriptor. 15295 // Allocate the instance descriptor.
15220 DescriptorArray* descriptors; 15296 DescriptorArray* descriptors;
15221 MaybeObject* maybe_descriptors = 15297 MaybeObject* maybe_descriptors =
15222 DescriptorArray::Allocate(instance_descriptor_length); 15298 DescriptorArray::Allocate(GetIsolate(), instance_descriptor_length);
15223 if (!maybe_descriptors->To(&descriptors)) { 15299 if (!maybe_descriptors->To(&descriptors)) {
15224 return maybe_descriptors; 15300 return maybe_descriptors;
15225 } 15301 }
15226 15302
15227 DescriptorArray::WhitenessWitness witness(descriptors); 15303 DescriptorArray::WhitenessWitness witness(descriptors);
15228 15304
15229 int number_of_allocated_fields = 15305 int number_of_allocated_fields =
15230 number_of_fields + unused_property_fields - inobject_props; 15306 number_of_fields + unused_property_fields - inobject_props;
15231 if (number_of_allocated_fields < 0) { 15307 if (number_of_allocated_fields < 0) {
15232 // There is enough inobject space for all fields (including unused). 15308 // There is enough inobject space for all fields (including unused).
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
15505 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); 15581 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value();
15506 return BreakPointInfo::cast(break_points()->get(index)); 15582 return BreakPointInfo::cast(break_points()->get(index));
15507 } 15583 }
15508 15584
15509 15585
15510 // Clear a break point at the specified code position. 15586 // Clear a break point at the specified code position.
15511 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, 15587 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info,
15512 int code_position, 15588 int code_position,
15513 Handle<Object> break_point_object) { 15589 Handle<Object> break_point_object) {
15514 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position), 15590 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
15515 Isolate::Current()); 15591 debug_info->GetIsolate());
15516 if (break_point_info->IsUndefined()) return; 15592 if (break_point_info->IsUndefined()) return;
15517 BreakPointInfo::ClearBreakPoint( 15593 BreakPointInfo::ClearBreakPoint(
15518 Handle<BreakPointInfo>::cast(break_point_info), 15594 Handle<BreakPointInfo>::cast(break_point_info),
15519 break_point_object); 15595 break_point_object);
15520 } 15596 }
15521 15597
15522 15598
15523 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, 15599 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
15524 int code_position, 15600 int code_position,
15525 int source_position, 15601 int source_position,
15526 int statement_position, 15602 int statement_position,
15527 Handle<Object> break_point_object) { 15603 Handle<Object> break_point_object) {
15528 Isolate* isolate = Isolate::Current(); 15604 Isolate* isolate = debug_info->GetIsolate();
15529 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position), 15605 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position),
15530 isolate); 15606 isolate);
15531 if (!break_point_info->IsUndefined()) { 15607 if (!break_point_info->IsUndefined()) {
15532 BreakPointInfo::SetBreakPoint( 15608 BreakPointInfo::SetBreakPoint(
15533 Handle<BreakPointInfo>::cast(break_point_info), 15609 Handle<BreakPointInfo>::cast(break_point_info),
15534 break_point_object); 15610 break_point_object);
15535 return; 15611 return;
15536 } 15612 }
15537 15613
15538 // Adding a new break point for a code position which did not have any 15614 // Adding a new break point for a code position which did not have any
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
15632 } 15708 }
15633 } 15709 }
15634 } 15710 }
15635 return kNoBreakPointInfo; 15711 return kNoBreakPointInfo;
15636 } 15712 }
15637 15713
15638 15714
15639 // Remove the specified break point object. 15715 // Remove the specified break point object.
15640 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, 15716 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
15641 Handle<Object> break_point_object) { 15717 Handle<Object> break_point_object) {
15642 Isolate* isolate = Isolate::Current(); 15718 Isolate* isolate = break_point_info->GetIsolate();
15643 // If there are no break points just ignore. 15719 // If there are no break points just ignore.
15644 if (break_point_info->break_point_objects()->IsUndefined()) return; 15720 if (break_point_info->break_point_objects()->IsUndefined()) return;
15645 // If there is a single break point clear it if it is the same. 15721 // If there is a single break point clear it if it is the same.
15646 if (!break_point_info->break_point_objects()->IsFixedArray()) { 15722 if (!break_point_info->break_point_objects()->IsFixedArray()) {
15647 if (break_point_info->break_point_objects() == *break_point_object) { 15723 if (break_point_info->break_point_objects() == *break_point_object) {
15648 break_point_info->set_break_point_objects( 15724 break_point_info->set_break_point_objects(
15649 isolate->heap()->undefined_value()); 15725 isolate->heap()->undefined_value());
15650 } 15726 }
15651 return; 15727 return;
15652 } 15728 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
15972 #define ERROR_MESSAGES_TEXTS(C, T) T, 16048 #define ERROR_MESSAGES_TEXTS(C, T) T,
15973 static const char* error_messages_[] = { 16049 static const char* error_messages_[] = {
15974 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16050 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
15975 }; 16051 };
15976 #undef ERROR_MESSAGES_TEXTS 16052 #undef ERROR_MESSAGES_TEXTS
15977 return error_messages_[reason]; 16053 return error_messages_[reason];
15978 } 16054 }
15979 16055
15980 16056
15981 } } // namespace v8::internal 16057 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698