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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 // objects or doing negative lookup for slow objects, ensures that the | 465 // objects or doing negative lookup for slow objects, ensures that the |
466 // property cells for global objects are still empty) and checks that the map | 466 // property cells for global objects are still empty) and checks that the map |
467 // of the holder has not changed. If necessary the function also generates | 467 // of the holder has not changed. If necessary the function also generates |
468 // code for security check in case of global object holders. Helps to make | 468 // code for security check in case of global object holders. Helps to make |
469 // sure that the current IC is still valid. | 469 // sure that the current IC is still valid. |
470 // | 470 // |
471 // The scratch and holder registers are always clobbered, but the object | 471 // The scratch and holder registers are always clobbered, but the object |
472 // register is only clobbered if it the same as the holder register. The | 472 // register is only clobbered if it the same as the holder register. The |
473 // function returns a register containing the holder - either object_reg or | 473 // function returns a register containing the holder - either object_reg or |
474 // holder_reg. | 474 // holder_reg. |
475 // The function can optionally (when save_at_depth != | |
476 // kInvalidProtoDepth) save the object at the given depth by moving | |
477 // it to [esp + kPointerSize]. | |
478 Register CheckPrototypes(Handle<HeapType> type, | 475 Register CheckPrototypes(Handle<HeapType> type, |
479 Register object_reg, | 476 Register object_reg, |
480 Handle<JSObject> holder, | 477 Handle<JSObject> holder, |
481 Register holder_reg, | 478 Register holder_reg, |
482 Register scratch1, | 479 Register scratch1, |
483 Register scratch2, | 480 Register scratch2, |
484 Handle<Name> name, | 481 Handle<Name> name, |
485 Label* miss, | 482 Label* miss, |
486 PrototypeCheckType check = CHECK_ALL_MAPS) { | |
487 return CheckPrototypes(type, object_reg, holder, holder_reg, scratch1, | |
488 scratch2, name, kInvalidProtoDepth, miss, check); | |
489 } | |
490 | |
491 Register CheckPrototypes(Handle<HeapType> type, | |
492 Register object_reg, | |
493 Handle<JSObject> holder, | |
494 Register holder_reg, | |
495 Register scratch1, | |
496 Register scratch2, | |
497 Handle<Name> name, | |
498 int save_at_depth, | |
499 Label* miss, | |
500 PrototypeCheckType check = CHECK_ALL_MAPS); | 483 PrototypeCheckType check = CHECK_ALL_MAPS); |
501 | 484 |
502 void GenerateBooleanCheck(Register object, Label* miss); | 485 void GenerateBooleanCheck(Register object, Label* miss); |
503 | 486 |
504 protected: | 487 protected: |
505 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); | 488 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); |
506 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<Name> name); | 489 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<Name> name); |
507 | 490 |
508 ExtraICState extra_state() { return extra_ic_state_; } | 491 ExtraICState extra_state() { return extra_ic_state_; } |
509 | 492 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 Handle<FunctionTemplateInfo> expected_receiver_type() const { | 1004 Handle<FunctionTemplateInfo> expected_receiver_type() const { |
1022 ASSERT(is_simple_api_call()); | 1005 ASSERT(is_simple_api_call()); |
1023 return expected_receiver_type_; | 1006 return expected_receiver_type_; |
1024 } | 1007 } |
1025 | 1008 |
1026 Handle<CallHandlerInfo> api_call_info() const { | 1009 Handle<CallHandlerInfo> api_call_info() const { |
1027 ASSERT(is_simple_api_call()); | 1010 ASSERT(is_simple_api_call()); |
1028 return api_call_info_; | 1011 return api_call_info_; |
1029 } | 1012 } |
1030 | 1013 |
1031 // Returns the depth of the object having the expected type in the | 1014 enum HolderLookup { |
1032 // prototype chain between the two arguments. | 1015 kHolderNotFound, |
1033 int GetPrototypeDepthOfExpectedType(Handle<JSObject> object, | 1016 kHolderIsReceiver, |
1034 Handle<JSObject> holder) const; | 1017 kHolderIsPrototypeOfMap |
| 1018 }; |
| 1019 // Returns a map whose prototype has the expected type in the |
| 1020 // prototype chain between the two arguments |
| 1021 // null will be returned if the first argument has that property |
| 1022 // lookup will be set accordingly |
| 1023 Handle<Map> LookupHolderOfExpectedType(Handle<JSObject> receiver, |
| 1024 Handle<JSObject> object, |
| 1025 Handle<JSObject> holder, |
| 1026 HolderLookup* holder_lookup) const; |
1035 | 1027 |
1036 bool IsCompatibleReceiver(Object* receiver) { | 1028 bool IsCompatibleReceiver(Object* receiver) { |
1037 ASSERT(is_simple_api_call()); | 1029 ASSERT(is_simple_api_call()); |
1038 if (expected_receiver_type_.is_null()) return true; | 1030 if (expected_receiver_type_.is_null()) return true; |
1039 return expected_receiver_type_->IsTemplateFor(receiver); | 1031 return expected_receiver_type_->IsTemplateFor(receiver); |
1040 } | 1032 } |
1041 | 1033 |
1042 private: | 1034 private: |
1043 void Initialize(Handle<JSFunction> function); | 1035 void Initialize(Handle<JSFunction> function); |
1044 | 1036 |
1045 // Determines whether the given function can be called using the | 1037 // Determines whether the given function can be called using the |
1046 // fast api call builtin. | 1038 // fast api call builtin. |
1047 void AnalyzePossibleApiFunction(Handle<JSFunction> function); | 1039 void AnalyzePossibleApiFunction(Handle<JSFunction> function); |
1048 | 1040 |
1049 Handle<JSFunction> constant_function_; | 1041 Handle<JSFunction> constant_function_; |
1050 bool is_simple_api_call_; | 1042 bool is_simple_api_call_; |
1051 Handle<FunctionTemplateInfo> expected_receiver_type_; | 1043 Handle<FunctionTemplateInfo> expected_receiver_type_; |
1052 Handle<CallHandlerInfo> api_call_info_; | 1044 Handle<CallHandlerInfo> api_call_info_; |
1053 }; | 1045 }; |
1054 | 1046 |
1055 | 1047 |
1056 } } // namespace v8::internal | 1048 } } // namespace v8::internal |
1057 | 1049 |
1058 #endif // V8_STUB_CACHE_H_ | 1050 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |