| OLD | NEW |
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 if (IsBoolean()) return IsTrue(); | 113 if (IsBoolean()) return IsTrue(); |
| 114 if (IsSmi()) return Smi::cast(this)->value() != 0; | 114 if (IsSmi()) return Smi::cast(this)->value() != 0; |
| 115 if (IsUndefined() || IsNull()) return false; | 115 if (IsUndefined() || IsNull()) return false; |
| 116 if (IsUndetectableObject()) return false; // Undetectable object is false. | 116 if (IsUndetectableObject()) return false; // Undetectable object is false. |
| 117 if (IsString()) return String::cast(this)->length() != 0; | 117 if (IsString()) return String::cast(this)->length() != 0; |
| 118 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); | 118 if (IsHeapNumber()) return HeapNumber::cast(this)->HeapNumberBooleanValue(); |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 bool Object::IsCallable() { |
| 124 Object* fun = this; |
| 125 while (fun->IsJSFunctionProxy()) { |
| 126 fun = JSFunctionProxy::cast(fun)->call_trap(); |
| 127 } |
| 128 return fun->IsJSFunction() || |
| 129 (fun->IsHeapObject() && |
| 130 HeapObject::cast(fun)->map()->has_instance_call_handler()); |
| 131 } |
| 132 |
| 133 |
| 123 void Object::Lookup(Name* name, LookupResult* result) { | 134 void Object::Lookup(Name* name, LookupResult* result) { |
| 124 Object* holder = NULL; | 135 Object* holder = NULL; |
| 125 if (IsJSReceiver()) { | 136 if (IsJSReceiver()) { |
| 126 holder = this; | 137 holder = this; |
| 127 } else { | 138 } else { |
| 128 Context* native_context = result->isolate()->context()->native_context(); | 139 Context* native_context = result->isolate()->context()->native_context(); |
| 129 if (IsNumber()) { | 140 if (IsNumber()) { |
| 130 holder = native_context->number_function()->instance_prototype(); | 141 holder = native_context->number_function()->instance_prototype(); |
| 131 } else if (IsString()) { | 142 } else if (IsString()) { |
| 132 holder = native_context->string_function()->instance_prototype(); | 143 holder = native_context->string_function()->instance_prototype(); |
| (...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 | 2222 |
| 2212 Execution::Call(isolate, | 2223 Execution::Call(isolate, |
| 2213 Handle<JSFunction>(isolate->observers_notify_change()), | 2224 Handle<JSFunction>(isolate->observers_notify_change()), |
| 2214 isolate->factory()->undefined_value(), | 2225 isolate->factory()->undefined_value(), |
| 2215 argc, args, | 2226 argc, args, |
| 2216 &threw); | 2227 &threw); |
| 2217 ASSERT(!threw); | 2228 ASSERT(!threw); |
| 2218 } | 2229 } |
| 2219 | 2230 |
| 2220 | 2231 |
| 2221 void JSObject::DeliverChangeRecords(Isolate* isolate) { | |
| 2222 ASSERT(isolate->observer_delivery_pending()); | |
| 2223 bool threw = false; | |
| 2224 Execution::Call( | |
| 2225 isolate, | |
| 2226 isolate->observers_deliver_changes(), | |
| 2227 isolate->factory()->undefined_value(), | |
| 2228 0, | |
| 2229 NULL, | |
| 2230 &threw); | |
| 2231 ASSERT(!threw); | |
| 2232 isolate->set_observer_delivery_pending(false); | |
| 2233 } | |
| 2234 | |
| 2235 | |
| 2236 Handle<Object> JSObject::SetPropertyPostInterceptor( | 2232 Handle<Object> JSObject::SetPropertyPostInterceptor( |
| 2237 Handle<JSObject> object, | 2233 Handle<JSObject> object, |
| 2238 Handle<Name> name, | 2234 Handle<Name> name, |
| 2239 Handle<Object> value, | 2235 Handle<Object> value, |
| 2240 PropertyAttributes attributes, | 2236 PropertyAttributes attributes, |
| 2241 StrictModeFlag strict_mode) { | 2237 StrictModeFlag strict_mode) { |
| 2242 // Check local property, ignore interceptor. | 2238 // Check local property, ignore interceptor. |
| 2243 LookupResult result(object->GetIsolate()); | 2239 LookupResult result(object->GetIsolate()); |
| 2244 object->LocalLookupRealNamedProperty(*name, &result); | 2240 object->LocalLookupRealNamedProperty(*name, &result); |
| 2245 if (!result.IsFound()) { | 2241 if (!result.IsFound()) { |
| (...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5711 } | 5707 } |
| 5712 } | 5708 } |
| 5713 | 5709 |
| 5714 if (object->map()->is_deprecated()) { | 5710 if (object->map()->is_deprecated()) { |
| 5715 JSObject::MigrateInstance(object); | 5711 JSObject::MigrateInstance(object); |
| 5716 } | 5712 } |
| 5717 | 5713 |
| 5718 Handle<JSObject> copy; | 5714 Handle<JSObject> copy; |
| 5719 if (copying) { | 5715 if (copying) { |
| 5720 Handle<AllocationSite> site_to_pass; | 5716 Handle<AllocationSite> site_to_pass; |
| 5721 if (site_context()->activated() && | 5717 if (site_context()->ShouldCreateMemento(object)) { |
| 5722 AllocationSite::CanTrack(object->map()->instance_type()) && | |
| 5723 AllocationSite::GetMode(object->GetElementsKind()) == | |
| 5724 TRACK_ALLOCATION_SITE) { | |
| 5725 site_to_pass = site_context()->current(); | 5718 site_to_pass = site_context()->current(); |
| 5726 } | 5719 } |
| 5727 CALL_AND_RETRY_OR_DIE(isolate, | 5720 CALL_AND_RETRY_OR_DIE(isolate, |
| 5728 isolate->heap()->CopyJSObject(*object, | 5721 isolate->heap()->CopyJSObject(*object, |
| 5729 site_to_pass.is_null() ? NULL : *site_to_pass), | 5722 site_to_pass.is_null() ? NULL : *site_to_pass), |
| 5730 { copy = Handle<JSObject>(JSObject::cast(__object__), | 5723 { copy = Handle<JSObject>(JSObject::cast(__object__), |
| 5731 isolate); | 5724 isolate); |
| 5732 break; | 5725 break; |
| 5733 }, | 5726 }, |
| 5734 return Handle<JSObject>()); | 5727 return Handle<JSObject>()); |
| (...skipping 3439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9174 | 9167 |
| 9175 | 9168 |
| 9176 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9169 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
| 9177 return string; | 9170 return string; |
| 9178 } | 9171 } |
| 9179 | 9172 |
| 9180 | 9173 |
| 9181 AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, | 9174 AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, |
| 9182 bool in_GC) { | 9175 bool in_GC) { |
| 9183 // Currently, AllocationMemento objects are only allocated immediately | 9176 // Currently, AllocationMemento objects are only allocated immediately |
| 9184 // after JSArrays in NewSpace, and detecting whether a JSArray has one | 9177 // after JSArrays and some JSObjects in NewSpace. Detecting whether a |
| 9185 // involves carefully checking the object immediately after the JSArray | 9178 // memento is present involves carefully checking the object immediately |
| 9186 // (if there is one) to see if it's an AllocationMemento. | 9179 // after the current object (if there is one) to see if it's an |
| 9180 // AllocationMemento. |
| 9187 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { | 9181 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { |
| 9188 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + | 9182 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + |
| 9189 object->Size(); | 9183 object->Size(); |
| 9190 Address top; | 9184 Address top; |
| 9191 if (in_GC) { | 9185 if (in_GC) { |
| 9192 top = object->GetHeap()->new_space()->FromSpacePageHigh(); | 9186 top = object->GetHeap()->new_space()->FromSpacePageHigh(); |
| 9193 } else { | 9187 } else { |
| 9194 top = object->GetHeap()->NewSpaceTop(); | 9188 top = object->GetHeap()->NewSpaceTop(); |
| 9195 } | 9189 } |
| 9196 if ((ptr_end + AllocationMemento::kSize) <= top) { | 9190 if ((ptr_end + AllocationMemento::kSize) <= top) { |
| 9197 // There is room in newspace for allocation info. Do we have some? | 9191 // There is room in newspace for allocation info. Do we have some? |
| 9198 Map** possible_allocation_memento_map = | 9192 Map** possible_allocation_memento_map = |
| 9199 reinterpret_cast<Map**>(ptr_end); | 9193 reinterpret_cast<Map**>(ptr_end); |
| 9200 if (*possible_allocation_memento_map == | 9194 if (*possible_allocation_memento_map == |
| 9201 object->GetHeap()->allocation_memento_map()) { | 9195 object->GetHeap()->allocation_memento_map()) { |
| 9202 AllocationMemento* memento = AllocationMemento::cast( | 9196 AllocationMemento* memento = AllocationMemento::cast( |
| 9203 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); | 9197 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); |
| 9204 return memento; | 9198 if (memento->IsValid()) { |
| 9199 return memento; |
| 9200 } |
| 9205 } | 9201 } |
| 9206 } | 9202 } |
| 9207 } | 9203 } |
| 9208 return NULL; | 9204 return NULL; |
| 9209 } | 9205 } |
| 9210 | 9206 |
| 9211 | 9207 |
| 9212 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { | 9208 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { |
| 9213 // For array indexes mix the length into the hash as an array index could | 9209 // For array indexes mix the length into the hash as an array index could |
| 9214 // be zero. | 9210 // be zero. |
| (...skipping 3567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12782 } | 12778 } |
| 12783 | 12779 |
| 12784 | 12780 |
| 12785 void JSObject::TransitionElementsKind(Handle<JSObject> object, | 12781 void JSObject::TransitionElementsKind(Handle<JSObject> object, |
| 12786 ElementsKind to_kind) { | 12782 ElementsKind to_kind) { |
| 12787 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), | 12783 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), |
| 12788 object->TransitionElementsKind(to_kind)); | 12784 object->TransitionElementsKind(to_kind)); |
| 12789 } | 12785 } |
| 12790 | 12786 |
| 12791 | 12787 |
| 12788 const double AllocationSite::kPretenureRatio = 0.60; |
| 12789 |
| 12790 |
| 12792 bool AllocationSite::IsNestedSite() { | 12791 bool AllocationSite::IsNestedSite() { |
| 12793 ASSERT(FLAG_trace_track_allocation_sites); | 12792 ASSERT(FLAG_trace_track_allocation_sites); |
| 12794 Object* current = GetHeap()->allocation_sites_list(); | 12793 Object* current = GetHeap()->allocation_sites_list(); |
| 12795 while (current != NULL && current->IsAllocationSite()) { | 12794 while (current != NULL && current->IsAllocationSite()) { |
| 12796 AllocationSite* current_site = AllocationSite::cast(current); | 12795 AllocationSite* current_site = AllocationSite::cast(current); |
| 12797 if (current_site->nested_site() == this) { | 12796 if (current_site->nested_site() == this) { |
| 12798 return true; | 12797 return true; |
| 12799 } | 12798 } |
| 12800 current = current_site->weak_next(); | 12799 current = current_site->weak_next(); |
| 12801 } | 12800 } |
| (...skipping 3850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16652 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16651 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16653 static const char* error_messages_[] = { | 16652 static const char* error_messages_[] = { |
| 16654 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16655 }; | 16654 }; |
| 16656 #undef ERROR_MESSAGES_TEXTS | 16655 #undef ERROR_MESSAGES_TEXTS |
| 16657 return error_messages_[reason]; | 16656 return error_messages_[reason]; |
| 16658 } | 16657 } |
| 16659 | 16658 |
| 16660 | 16659 |
| 16661 } } // namespace v8::internal | 16660 } } // namespace v8::internal |
| OLD | NEW |