OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 ASSERT(IsFound()); | 229 ASSERT(IsFound()); |
230 return IsTransition() || type() != NORMAL; | 230 return IsTransition() || type() != NORMAL; |
231 } | 231 } |
232 | 232 |
233 // Property callbacks does not include transitions to callbacks. | 233 // Property callbacks does not include transitions to callbacks. |
234 bool IsPropertyCallbacks() { | 234 bool IsPropertyCallbacks() { |
235 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); | 235 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); |
236 return details_.type() == CALLBACKS; | 236 return details_.type() == CALLBACKS; |
237 } | 237 } |
238 | 238 |
239 // Is callbacks contains both property callbacks and transitions to callbacks. | |
240 bool IsCallbacks() { | |
241 return IsPropertyCallbacks() || | |
242 (IsTransition() && GetTransitionValue()->IsAccessorPair()); | |
243 } | |
244 | |
245 bool IsReadOnly() { | 239 bool IsReadOnly() { |
246 ASSERT(IsFound()); | 240 ASSERT(IsFound()); |
247 ASSERT(!IsTransition()); | 241 ASSERT(!IsTransition()); |
248 ASSERT(details_.type() != NONEXISTENT); | 242 ASSERT(details_.type() != NONEXISTENT); |
249 return details_.IsReadOnly(); | 243 return details_.IsReadOnly(); |
250 } | 244 } |
251 | 245 |
252 bool IsField() { | 246 bool IsField() { |
253 ASSERT(!(details_.type() == FIELD && !IsFound())); | 247 ASSERT(!(details_.type() == FIELD && !IsFound())); |
254 return details_.type() == FIELD; | 248 return details_.type() == FIELD; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } | 286 } |
293 return value; | 287 return value; |
294 } | 288 } |
295 case CONSTANT_FUNCTION: | 289 case CONSTANT_FUNCTION: |
296 return GetConstantFunction(); | 290 return GetConstantFunction(); |
297 default: | 291 default: |
298 return Smi::FromInt(0); | 292 return Smi::FromInt(0); |
299 } | 293 } |
300 } | 294 } |
301 | 295 |
302 Object* GetTransitionValue() { | 296 Map* GetTransitionTarget() { |
303 ASSERT(IsTransition()); | 297 ASSERT(IsTransition()); |
304 TransitionArray* transitions = holder()->map()->transitions(); | 298 TransitionArray* transitions = holder()->map()->transitions(); |
305 Object* value = transitions->GetValue(number_); | 299 return transitions->GetTarget(number_); |
306 return value; | |
307 } | 300 } |
308 | 301 |
309 PropertyDetails GetTransitionDetails(Map* map) { | 302 PropertyDetails GetTransitionDetails(Map* map) { |
310 ASSERT(IsTransition()); | 303 ASSERT(IsTransition()); |
311 TransitionArray* transitions = map->transitions(); | 304 TransitionArray* transitions = map->transitions(); |
312 return transitions->GetTargetDetails(number_); | 305 return transitions->GetTargetDetails(number_); |
313 } | 306 } |
314 | 307 |
315 PropertyDetails GetTransitionDetails() { | 308 PropertyDetails GetTransitionDetails() { |
316 return GetTransitionDetails(holder()->map()); | 309 return GetTransitionDetails(holder()->map()); |
317 } | 310 } |
318 | 311 |
319 bool IsTransitionToField(Map* map) { | 312 bool IsTransitionToField(Map* map) { |
320 return IsTransition() && GetTransitionDetails(map).type() == FIELD; | 313 return IsTransition() && GetTransitionDetails(map).type() == FIELD; |
321 } | 314 } |
322 | 315 |
323 Map* GetTransitionMap() { | 316 Map* GetTransitionMap() { |
324 ASSERT(IsTransition()); | 317 ASSERT(IsTransition()); |
325 return Map::cast(GetValue()); | 318 return Map::cast(GetValue()); |
326 } | 319 } |
327 | 320 |
328 Map* GetTransitionMapFromMap(Map* map) { | 321 Map* GetTransitionMapFromMap(Map* map) { |
329 ASSERT(IsTransition()); | 322 ASSERT(IsTransition()); |
330 return Map::cast(map->transitions()->GetValue(number_)); | 323 return map->transitions()->GetTarget(number_); |
331 } | 324 } |
332 | 325 |
333 int GetTransitionIndex() { | 326 int GetTransitionIndex() { |
334 ASSERT(IsTransition()); | 327 ASSERT(IsTransition()); |
335 return number_; | 328 return number_; |
336 } | 329 } |
337 | 330 |
338 int GetFieldIndex() { | 331 int GetFieldIndex() { |
339 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 332 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
340 ASSERT(IsField()); | 333 ASSERT(IsField()); |
(...skipping 15 matching lines...) Expand all Loading... | |
356 ASSERT(type() == CONSTANT_FUNCTION); | 349 ASSERT(type() == CONSTANT_FUNCTION); |
357 return JSFunction::cast(GetValue()); | 350 return JSFunction::cast(GetValue()); |
358 } | 351 } |
359 | 352 |
360 JSFunction* GetConstantFunctionFromMap(Map* map) { | 353 JSFunction* GetConstantFunctionFromMap(Map* map) { |
361 ASSERT(type() == CONSTANT_FUNCTION); | 354 ASSERT(type() == CONSTANT_FUNCTION); |
362 return JSFunction::cast(GetValueFromMap(map)); | 355 return JSFunction::cast(GetValueFromMap(map)); |
363 } | 356 } |
364 | 357 |
365 Object* GetCallbackObject() { | 358 Object* GetCallbackObject() { |
366 switch (lookup_type_) { | 359 ASSERT(!IsTransition()); |
367 case CONSTANT_TYPE: | 360 if (lookup_type_ == CONSTANT_TYPE) { |
368 return HEAP->prototype_accessors(); | 361 return HEAP->prototype_accessors(); |
369 case TRANSITION_TYPE: | 362 } else { |
370 return GetTransitionValue(); | 363 return GetValue(); |
Sven Panne
2012/07/16 13:49:43
Can we put an ASSERT here about the lookup_type_?
| |
371 default: | |
372 return GetValue(); | |
373 } | 364 } |
374 } | 365 } |
375 | 366 |
376 #ifdef OBJECT_PRINT | 367 #ifdef OBJECT_PRINT |
377 void Print(FILE* out); | 368 void Print(FILE* out); |
378 #endif | 369 #endif |
379 | 370 |
380 Object* GetValue() { | 371 Object* GetValue() { |
381 if (lookup_type_ == DESCRIPTOR_TYPE) { | 372 if (lookup_type_ == DESCRIPTOR_TYPE) { |
382 return GetValueFromMap(holder()->map()); | 373 return GetValueFromMap(holder()->map()); |
(...skipping 28 matching lines...) Expand all Loading... | |
411 JSReceiver* holder_; | 402 JSReceiver* holder_; |
412 int number_; | 403 int number_; |
413 bool cacheable_; | 404 bool cacheable_; |
414 PropertyDetails details_; | 405 PropertyDetails details_; |
415 }; | 406 }; |
416 | 407 |
417 | 408 |
418 } } // namespace v8::internal | 409 } } // namespace v8::internal |
419 | 410 |
420 #endif // V8_PROPERTY_H_ | 411 #endif // V8_PROPERTY_H_ |
OLD | NEW |