Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: src/builtins.cc

Issue 6931056: Check that receiver is JSObject on API calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 // with this receiver. Returns Heap::null_value() if the call is 1019 // with this receiver. Returns Heap::null_value() if the call is
1020 // illegal. Any arguments that don't fit the expected type is 1020 // illegal. Any arguments that don't fit the expected type is
1021 // overwritten with undefined. Arguments that do fit the expected 1021 // overwritten with undefined. Arguments that do fit the expected
1022 // type is overwritten with the object in the prototype chain that 1022 // type is overwritten with the object in the prototype chain that
1023 // actually has that type. 1023 // actually has that type.
1024 static inline Object* TypeCheck(Heap* heap, 1024 static inline Object* TypeCheck(Heap* heap,
1025 int argc, 1025 int argc,
1026 Object** argv, 1026 Object** argv,
1027 FunctionTemplateInfo* info) { 1027 FunctionTemplateInfo* info) {
1028 Object* recv = argv[0]; 1028 Object* recv = argv[0];
1029 // API calls are only supported with JSObject receivers.
1030 if (!recv->IsJSObject()) return heap->null_value();
1029 Object* sig_obj = info->signature(); 1031 Object* sig_obj = info->signature();
1030 if (sig_obj->IsUndefined()) return recv; 1032 if (sig_obj->IsUndefined()) return recv;
1031 SignatureInfo* sig = SignatureInfo::cast(sig_obj); 1033 SignatureInfo* sig = SignatureInfo::cast(sig_obj);
1032 // If necessary, check the receiver 1034 // If necessary, check the receiver
1033 Object* recv_type = sig->receiver(); 1035 Object* recv_type = sig->receiver();
1034 1036
1035 Object* holder = recv; 1037 Object* holder = recv;
1036 if (!recv_type->IsUndefined()) { 1038 if (!recv_type->IsUndefined()) {
1037 for (; holder != heap->null_value(); holder = holder->GetPrototype()) { 1039 for (; holder != heap->null_value(); holder = holder->GetPrototype()) {
1038 if (holder->IsInstanceOf(FunctionTemplateInfo::cast(recv_type))) { 1040 if (holder->IsInstanceOf(FunctionTemplateInfo::cast(recv_type))) {
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 return Handle<Code>(code_address); \ 1701 return Handle<Code>(code_address); \
1700 } 1702 }
1701 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1703 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1702 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1704 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1703 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1705 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1704 #undef DEFINE_BUILTIN_ACCESSOR_C 1706 #undef DEFINE_BUILTIN_ACCESSOR_C
1705 #undef DEFINE_BUILTIN_ACCESSOR_A 1707 #undef DEFINE_BUILTIN_ACCESSOR_A
1706 1708
1707 1709
1708 } } // namespace v8::internal 1710 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698