| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bootstrapper.h" | 5 #include "bootstrapper.h" |
| 6 | 6 |
| 7 #include "accessors.h" | 7 #include "accessors.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "natives.h" | 9 #include "natives.h" |
| 10 #include "snapshot.h" | 10 #include "snapshot.h" |
| (...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 result, factory->length_string(), | 1104 result, factory->length_string(), |
| 1105 factory->undefined_value(), DONT_ENUM, | 1105 factory->undefined_value(), DONT_ENUM, |
| 1106 Object::FORCE_TAGGED, FORCE_FIELD).Check(); | 1106 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
| 1107 JSObject::SetLocalPropertyIgnoreAttributes( | 1107 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1108 result, factory->callee_string(), | 1108 result, factory->callee_string(), |
| 1109 factory->undefined_value(), DONT_ENUM, | 1109 factory->undefined_value(), DONT_ENUM, |
| 1110 Object::FORCE_TAGGED, FORCE_FIELD).Check(); | 1110 Object::FORCE_TAGGED, FORCE_FIELD).Check(); |
| 1111 | 1111 |
| 1112 #ifdef DEBUG | 1112 #ifdef DEBUG |
| 1113 LookupResult lookup(isolate); | 1113 LookupResult lookup(isolate); |
| 1114 result->LocalLookup(heap->callee_string(), &lookup); | 1114 result->LocalLookup(factory->callee_string(), &lookup); |
| 1115 ASSERT(lookup.IsField()); | 1115 ASSERT(lookup.IsField()); |
| 1116 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); | 1116 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsCalleeIndex); |
| 1117 | 1117 |
| 1118 result->LocalLookup(heap->length_string(), &lookup); | 1118 result->LocalLookup(factory->length_string(), &lookup); |
| 1119 ASSERT(lookup.IsField()); | 1119 ASSERT(lookup.IsField()); |
| 1120 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1120 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
| 1121 | 1121 |
| 1122 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex); | 1122 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex); |
| 1123 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1123 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1124 | 1124 |
| 1125 // Check the state of the object. | 1125 // Check the state of the object. |
| 1126 ASSERT(result->HasFastProperties()); | 1126 ASSERT(result->HasFastProperties()); |
| 1127 ASSERT(result->HasFastObjectElements()); | 1127 ASSERT(result->HasFastObjectElements()); |
| 1128 #endif | 1128 #endif |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1205 Handle<JSObject> result = factory->NewJSObjectFromMap(map); | 1205 Handle<JSObject> result = factory->NewJSObjectFromMap(map); |
| 1206 native_context()->set_strict_arguments_boilerplate(*result); | 1206 native_context()->set_strict_arguments_boilerplate(*result); |
| 1207 | 1207 |
| 1208 // Add length property only for strict mode boilerplate. | 1208 // Add length property only for strict mode boilerplate. |
| 1209 JSObject::SetLocalPropertyIgnoreAttributes( | 1209 JSObject::SetLocalPropertyIgnoreAttributes( |
| 1210 result, factory->length_string(), | 1210 result, factory->length_string(), |
| 1211 factory->undefined_value(), DONT_ENUM).Check(); | 1211 factory->undefined_value(), DONT_ENUM).Check(); |
| 1212 | 1212 |
| 1213 #ifdef DEBUG | 1213 #ifdef DEBUG |
| 1214 LookupResult lookup(isolate); | 1214 LookupResult lookup(isolate); |
| 1215 result->LocalLookup(heap->length_string(), &lookup); | 1215 result->LocalLookup(factory->length_string(), &lookup); |
| 1216 ASSERT(lookup.IsField()); | 1216 ASSERT(lookup.IsField()); |
| 1217 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); | 1217 ASSERT(lookup.GetFieldIndex().field_index() == Heap::kArgumentsLengthIndex); |
| 1218 | 1218 |
| 1219 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); | 1219 ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex); |
| 1220 | 1220 |
| 1221 // Check the state of the object. | 1221 // Check the state of the object. |
| 1222 ASSERT(result->HasFastProperties()); | 1222 ASSERT(result->HasFastProperties()); |
| 1223 ASSERT(result->HasFastObjectElements()); | 1223 ASSERT(result->HasFastObjectElements()); |
| 1224 #endif | 1224 #endif |
| 1225 } | 1225 } |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 case CONSTANT: { | 2406 case CONSTANT: { |
| 2407 HandleScope inner(isolate()); | 2407 HandleScope inner(isolate()); |
| 2408 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | 2408 Handle<Name> key = Handle<Name>(descs->GetKey(i)); |
| 2409 Handle<Object> constant(descs->GetConstant(i), isolate()); | 2409 Handle<Object> constant(descs->GetConstant(i), isolate()); |
| 2410 JSObject::SetLocalPropertyIgnoreAttributes( | 2410 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2411 to, key, constant, details.attributes()).Check(); | 2411 to, key, constant, details.attributes()).Check(); |
| 2412 break; | 2412 break; |
| 2413 } | 2413 } |
| 2414 case CALLBACKS: { | 2414 case CALLBACKS: { |
| 2415 LookupResult result(isolate()); | 2415 LookupResult result(isolate()); |
| 2416 to->LocalLookup(descs->GetKey(i), &result); | 2416 Handle<Name> key(Name::cast(descs->GetKey(i)), isolate()); |
| 2417 to->LocalLookup(key, &result); |
| 2417 // If the property is already there we skip it | 2418 // If the property is already there we skip it |
| 2418 if (result.IsFound()) continue; | 2419 if (result.IsFound()) continue; |
| 2419 HandleScope inner(isolate()); | 2420 HandleScope inner(isolate()); |
| 2420 ASSERT(!to->HasFastProperties()); | 2421 ASSERT(!to->HasFastProperties()); |
| 2421 // Add to dictionary. | 2422 // Add to dictionary. |
| 2422 Handle<Name> key = Handle<Name>(descs->GetKey(i)); | |
| 2423 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); | 2423 Handle<Object> callbacks(descs->GetCallbacksObject(i), isolate()); |
| 2424 PropertyDetails d = PropertyDetails( | 2424 PropertyDetails d = PropertyDetails( |
| 2425 details.attributes(), CALLBACKS, i + 1); | 2425 details.attributes(), CALLBACKS, i + 1); |
| 2426 JSObject::SetNormalizedProperty(to, key, callbacks, d); | 2426 JSObject::SetNormalizedProperty(to, key, callbacks, d); |
| 2427 break; | 2427 break; |
| 2428 } | 2428 } |
| 2429 case NORMAL: | 2429 case NORMAL: |
| 2430 // Do not occur since the from object has fast properties. | 2430 // Do not occur since the from object has fast properties. |
| 2431 case HANDLER: | 2431 case HANDLER: |
| 2432 case INTERCEPTOR: | 2432 case INTERCEPTOR: |
| 2433 case NONEXISTENT: | 2433 case NONEXISTENT: |
| 2434 // No element in instance descriptors have proxy or interceptor type. | 2434 // No element in instance descriptors have proxy or interceptor type. |
| 2435 UNREACHABLE(); | 2435 UNREACHABLE(); |
| 2436 break; | 2436 break; |
| 2437 } | 2437 } |
| 2438 } | 2438 } |
| 2439 } else { | 2439 } else { |
| 2440 Handle<NameDictionary> properties = | 2440 Handle<NameDictionary> properties = |
| 2441 Handle<NameDictionary>(from->property_dictionary()); | 2441 Handle<NameDictionary>(from->property_dictionary()); |
| 2442 int capacity = properties->Capacity(); | 2442 int capacity = properties->Capacity(); |
| 2443 for (int i = 0; i < capacity; i++) { | 2443 for (int i = 0; i < capacity; i++) { |
| 2444 Object* raw_key(properties->KeyAt(i)); | 2444 Object* raw_key(properties->KeyAt(i)); |
| 2445 if (properties->IsKey(raw_key)) { | 2445 if (properties->IsKey(raw_key)) { |
| 2446 ASSERT(raw_key->IsName()); | 2446 ASSERT(raw_key->IsName()); |
| 2447 // If the property is already there we skip it. | 2447 // If the property is already there we skip it. |
| 2448 LookupResult result(isolate()); | 2448 LookupResult result(isolate()); |
| 2449 to->LocalLookup(Name::cast(raw_key), &result); | 2449 Handle<Name> key(Name::cast(raw_key)); |
| 2450 to->LocalLookup(key, &result); |
| 2450 if (result.IsFound()) continue; | 2451 if (result.IsFound()) continue; |
| 2451 // Set the property. | 2452 // Set the property. |
| 2452 Handle<Name> key = Handle<Name>(Name::cast(raw_key)); | |
| 2453 Handle<Object> value = Handle<Object>(properties->ValueAt(i), | 2453 Handle<Object> value = Handle<Object>(properties->ValueAt(i), |
| 2454 isolate()); | 2454 isolate()); |
| 2455 ASSERT(!value->IsCell()); | 2455 ASSERT(!value->IsCell()); |
| 2456 if (value->IsPropertyCell()) { | 2456 if (value->IsPropertyCell()) { |
| 2457 value = Handle<Object>(PropertyCell::cast(*value)->value(), | 2457 value = Handle<Object>(PropertyCell::cast(*value)->value(), |
| 2458 isolate()); | 2458 isolate()); |
| 2459 } | 2459 } |
| 2460 PropertyDetails details = properties->DetailsAt(i); | 2460 PropertyDetails details = properties->DetailsAt(i); |
| 2461 JSObject::SetLocalPropertyIgnoreAttributes( | 2461 JSObject::SetLocalPropertyIgnoreAttributes( |
| 2462 to, key, value, details.attributes()).Check(); | 2462 to, key, value, details.attributes()).Check(); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 return from + sizeof(NestingCounterType); | 2691 return from + sizeof(NestingCounterType); |
| 2692 } | 2692 } |
| 2693 | 2693 |
| 2694 | 2694 |
| 2695 // Called when the top-level V8 mutex is destroyed. | 2695 // Called when the top-level V8 mutex is destroyed. |
| 2696 void Bootstrapper::FreeThreadResources() { | 2696 void Bootstrapper::FreeThreadResources() { |
| 2697 ASSERT(!IsActive()); | 2697 ASSERT(!IsActive()); |
| 2698 } | 2698 } |
| 2699 | 2699 |
| 2700 } } // namespace v8::internal | 2700 } } // namespace v8::internal |
| OLD | NEW |