| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 // --- T e m p l a t e --- | 693 // --- T e m p l a t e --- |
| 694 | 694 |
| 695 | 695 |
| 696 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { | 696 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { |
| 697 that->set_tag(i::Smi::FromInt(type)); | 697 that->set_tag(i::Smi::FromInt(type)); |
| 698 } | 698 } |
| 699 | 699 |
| 700 | 700 |
| 701 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, | 701 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, |
| 702 v8::PropertyAttribute attribute) { | 702 v8::PropertyAttribute attribute) { |
| 703 if (IsDeadCheck("v8::Template::SetProperty()")) return; | 703 if (IsDeadCheck("v8::Template::Set()")) return; |
| 704 ENTER_V8; | 704 ENTER_V8; |
| 705 HandleScope scope; | 705 HandleScope scope; |
| 706 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list()); | 706 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list()); |
| 707 if (list->IsUndefined()) { | 707 if (list->IsUndefined()) { |
| 708 list = NeanderArray().value(); | 708 list = NeanderArray().value(); |
| 709 Utils::OpenHandle(this)->set_property_list(*list); | 709 Utils::OpenHandle(this)->set_property_list(*list); |
| 710 } | 710 } |
| 711 NeanderArray array(list); | 711 NeanderArray array(list); |
| 712 array.add(Utils::OpenHandle(*name)); | 712 array.add(Utils::OpenHandle(*name)); |
| 713 array.add(Utils::OpenHandle(*value)); | 713 array.add(Utils::OpenHandle(*value)); |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 bool Value::Equals(Handle<Value> that) const { | 2230 bool Value::Equals(Handle<Value> that) const { |
| 2231 if (IsDeadCheck("v8::Value::Equals()") | 2231 if (IsDeadCheck("v8::Value::Equals()") |
| 2232 || EmptyCheck("v8::Value::Equals()", this) | 2232 || EmptyCheck("v8::Value::Equals()", this) |
| 2233 || EmptyCheck("v8::Value::Equals()", that)) { | 2233 || EmptyCheck("v8::Value::Equals()", that)) { |
| 2234 return false; | 2234 return false; |
| 2235 } | 2235 } |
| 2236 LOG_API("Equals"); | 2236 LOG_API("Equals"); |
| 2237 ENTER_V8; | 2237 ENTER_V8; |
| 2238 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2238 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
| 2239 i::Handle<i::Object> other = Utils::OpenHandle(*that); | 2239 i::Handle<i::Object> other = Utils::OpenHandle(*that); |
| 2240 // If both obj and other are JSObjects, we'd better compare by identity |
| 2241 // immediately when going into JS builtin. The reason is Invoke |
| 2242 // would overwrite global object receiver with global proxy. |
| 2243 if (obj->IsJSObject() && other->IsJSObject()) { |
| 2244 return *obj == *other; |
| 2245 } |
| 2240 i::Object** args[1] = { other.location() }; | 2246 i::Object** args[1] = { other.location() }; |
| 2241 EXCEPTION_PREAMBLE(); | 2247 EXCEPTION_PREAMBLE(); |
| 2242 i::Handle<i::Object> result = | 2248 i::Handle<i::Object> result = |
| 2243 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); | 2249 CallV8HeapFunction("EQUALS", obj, 1, args, &has_pending_exception); |
| 2244 EXCEPTION_BAILOUT_CHECK(false); | 2250 EXCEPTION_BAILOUT_CHECK(false); |
| 2245 return *result == i::Smi::FromInt(i::EQUAL); | 2251 return *result == i::Smi::FromInt(i::EQUAL); |
| 2246 } | 2252 } |
| 2247 | 2253 |
| 2248 | 2254 |
| 2249 bool Value::StrictEquals(Handle<Value> that) const { | 2255 bool Value::StrictEquals(Handle<Value> that) const { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2304 ENTER_V8; | 2310 ENTER_V8; |
| 2305 HandleScope scope; | 2311 HandleScope scope; |
| 2306 i::Handle<i::Object> self = Utils::OpenHandle(this); | 2312 i::Handle<i::Object> self = Utils::OpenHandle(this); |
| 2307 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 2313 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 2308 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 2314 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 2309 EXCEPTION_PREAMBLE(); | 2315 EXCEPTION_PREAMBLE(); |
| 2310 i::Handle<i::Object> obj = i::SetProperty( | 2316 i::Handle<i::Object> obj = i::SetProperty( |
| 2311 self, | 2317 self, |
| 2312 key_obj, | 2318 key_obj, |
| 2313 value_obj, | 2319 value_obj, |
| 2314 static_cast<PropertyAttributes>(attribs)); | 2320 static_cast<PropertyAttributes>(attribs), |
| 2321 i::kNonStrictMode); |
| 2315 has_pending_exception = obj.is_null(); | 2322 has_pending_exception = obj.is_null(); |
| 2316 EXCEPTION_BAILOUT_CHECK(false); | 2323 EXCEPTION_BAILOUT_CHECK(false); |
| 2317 return true; | 2324 return true; |
| 2318 } | 2325 } |
| 2319 | 2326 |
| 2320 | 2327 |
| 2321 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { | 2328 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { |
| 2322 ON_BAILOUT("v8::Object::Set()", return false); | 2329 ON_BAILOUT("v8::Object::Set()", return false); |
| 2323 ENTER_V8; | 2330 ENTER_V8; |
| 2324 HandleScope scope; | 2331 HandleScope scope; |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 EXCEPTION_BAILOUT_CHECK(Local<Object>()); | 2686 EXCEPTION_BAILOUT_CHECK(Local<Object>()); |
| 2680 return Utils::ToLocal(result); | 2687 return Utils::ToLocal(result); |
| 2681 } | 2688 } |
| 2682 | 2689 |
| 2683 | 2690 |
| 2684 int v8::Object::GetIdentityHash() { | 2691 int v8::Object::GetIdentityHash() { |
| 2685 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); | 2692 ON_BAILOUT("v8::Object::GetIdentityHash()", return 0); |
| 2686 ENTER_V8; | 2693 ENTER_V8; |
| 2687 HandleScope scope; | 2694 HandleScope scope; |
| 2688 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2695 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2689 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2696 i::Handle<i::Object> hidden_props_obj(i::GetHiddenProperties(self, true)); |
| 2690 i::Handle<i::Object> hash_symbol = FACTORY->identity_hash_symbol(); | 2697 if (!hidden_props_obj->IsJSObject()) { |
| 2691 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); | 2698 // We failed to create hidden properties. That's a detached |
| 2699 // global proxy. |
| 2700 ASSERT(hidden_props_obj->IsUndefined()); |
| 2701 return 0; |
| 2702 } |
| 2703 i::Handle<i::JSObject> hidden_props = |
| 2704 i::Handle<i::JSObject>::cast(hidden_props_obj); |
| 2705 i::Handle<i::String> hash_symbol = FACTORY->identity_hash_symbol(); |
| 2706 if (hidden_props->HasLocalProperty(*hash_symbol)) { |
| 2707 i::Handle<i::Object> hash = i::GetProperty(hidden_props, hash_symbol); |
| 2708 CHECK(!hash.is_null()); |
| 2709 CHECK(hash->IsSmi()); |
| 2710 return i::Smi::cast(*hash)->value(); |
| 2711 } |
| 2712 |
| 2692 int hash_value; | 2713 int hash_value; |
| 2693 if (hash->IsSmi()) { | 2714 int attempts = 0; |
| 2694 hash_value = i::Smi::cast(*hash)->value(); | 2715 do { |
| 2695 } else { | 2716 // Generate a random 32-bit hash value but limit range to fit |
| 2696 int attempts = 0; | 2717 // within a smi. |
| 2697 do { | 2718 hash_value = i::V8::Random(self->GetIsolate()) & i::Smi::kMaxValue; |
| 2698 // Generate a random 32-bit hash value but limit range to fit | 2719 attempts++; |
| 2699 // within a smi. | 2720 } while (hash_value == 0 && attempts < 30); |
| 2700 hash_value = i::V8::Random(self->GetIsolate()) & i::Smi::kMaxValue; | 2721 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 |
| 2701 attempts++; | 2722 CHECK(!i::SetLocalPropertyIgnoreAttributes( |
| 2702 } while (hash_value == 0 && attempts < 30); | 2723 hidden_props, |
| 2703 hash_value = hash_value != 0 ? hash_value : 1; // never return 0 | 2724 hash_symbol, |
| 2704 i::SetProperty(hidden_props, | 2725 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |
| 2705 hash_symbol, | 2726 static_cast<PropertyAttributes>(None)).is_null()); |
| 2706 i::Handle<i::Object>(i::Smi::FromInt(hash_value)), | 2727 |
| 2707 static_cast<PropertyAttributes>(None)); | |
| 2708 } | |
| 2709 return hash_value; | 2728 return hash_value; |
| 2710 } | 2729 } |
| 2711 | 2730 |
| 2712 | 2731 |
| 2713 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, | 2732 bool v8::Object::SetHiddenValue(v8::Handle<v8::String> key, |
| 2714 v8::Handle<v8::Value> value) { | 2733 v8::Handle<v8::Value> value) { |
| 2715 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); | 2734 ON_BAILOUT("v8::Object::SetHiddenValue()", return false); |
| 2716 ENTER_V8; | 2735 ENTER_V8; |
| 2717 HandleScope scope; | 2736 HandleScope scope; |
| 2718 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2737 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2719 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); | 2738 i::Handle<i::Object> hidden_props(i::GetHiddenProperties(self, true)); |
| 2720 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 2739 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 2721 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 2740 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 2722 EXCEPTION_PREAMBLE(); | 2741 EXCEPTION_PREAMBLE(); |
| 2723 i::Handle<i::Object> obj = i::SetProperty( | 2742 i::Handle<i::Object> obj = i::SetProperty( |
| 2724 hidden_props, | 2743 hidden_props, |
| 2725 key_obj, | 2744 key_obj, |
| 2726 value_obj, | 2745 value_obj, |
| 2727 static_cast<PropertyAttributes>(None)); | 2746 static_cast<PropertyAttributes>(None), |
| 2747 i::kNonStrictMode); |
| 2728 has_pending_exception = obj.is_null(); | 2748 has_pending_exception = obj.is_null(); |
| 2729 EXCEPTION_BAILOUT_CHECK(false); | 2749 EXCEPTION_BAILOUT_CHECK(false); |
| 2730 return true; | 2750 return true; |
| 2731 } | 2751 } |
| 2732 | 2752 |
| 2733 | 2753 |
| 2734 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { | 2754 v8::Local<v8::Value> v8::Object::GetHiddenValue(v8::Handle<v8::String> key) { |
| 2735 ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>()); | 2755 ON_BAILOUT("v8::Object::GetHiddenValue()", return Local<v8::Value>()); |
| 2736 ENTER_V8; | 2756 ENTER_V8; |
| 2737 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2757 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2775 "length exceeds max acceptable value")) { | 2795 "length exceeds max acceptable value")) { |
| 2776 return; | 2796 return; |
| 2777 } | 2797 } |
| 2778 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2798 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2779 if (!ApiCheck(!self->IsJSArray(), | 2799 if (!ApiCheck(!self->IsJSArray(), |
| 2780 "v8::Object::SetIndexedPropertiesToPixelData()", | 2800 "v8::Object::SetIndexedPropertiesToPixelData()", |
| 2781 "JSArray is not supported")) { | 2801 "JSArray is not supported")) { |
| 2782 return; | 2802 return; |
| 2783 } | 2803 } |
| 2784 i::Handle<i::PixelArray> pixels = FACTORY->NewPixelArray(length, data); | 2804 i::Handle<i::PixelArray> pixels = FACTORY->NewPixelArray(length, data); |
| 2785 i::Handle<i::Map> slow_map = | 2805 i::Handle<i::Map> pixel_array_map = |
| 2786 FACTORY->GetSlowElementsMap(i::Handle<i::Map>(self->map())); | 2806 FACTORY->GetPixelArrayElementsMap(i::Handle<i::Map>(self->map())); |
| 2787 self->set_map(*slow_map); | 2807 self->set_map(*pixel_array_map); |
| 2788 self->set_elements(*pixels); | 2808 self->set_elements(*pixels); |
| 2789 } | 2809 } |
| 2790 | 2810 |
| 2791 | 2811 |
| 2792 bool v8::Object::HasIndexedPropertiesInPixelData() { | 2812 bool v8::Object::HasIndexedPropertiesInPixelData() { |
| 2793 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false); | 2813 ON_BAILOUT("v8::HasIndexedPropertiesInPixelData()", return false); |
| 2794 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2814 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2795 return self->HasPixelElements(); | 2815 return self->HasPixelElements(); |
| 2796 } | 2816 } |
| 2797 | 2817 |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5184 | 5204 |
| 5185 | 5205 |
| 5186 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 5206 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5187 HandleScopeImplementer* thread_local = | 5207 HandleScopeImplementer* thread_local = |
| 5188 reinterpret_cast<HandleScopeImplementer*>(storage); | 5208 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5189 thread_local->IterateThis(v); | 5209 thread_local->IterateThis(v); |
| 5190 return storage + ArchiveSpacePerThread(); | 5210 return storage + ArchiveSpacePerThread(); |
| 5191 } | 5211 } |
| 5192 | 5212 |
| 5193 } } // namespace v8::internal | 5213 } } // namespace v8::internal |
| OLD | NEW |