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

Side by Side Diff: src/objects.cc

Issue 1036743004: add access checks to receivers on function callbacks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-accessors.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 type->IsFunctionTemplateInfo(); 234 type->IsFunctionTemplateInfo();
235 type = FunctionTemplateInfo::cast(type)->parent_template()) { 235 type = FunctionTemplateInfo::cast(type)->parent_template()) {
236 if (type == this) return true; 236 if (type == this) return true;
237 } 237 }
238 // Didn't find the required type in the inheritance chain. 238 // Didn't find the required type in the inheritance chain.
239 return false; 239 return false;
240 } 240 }
241 241
242 242
243 // TODO(dcarney): CallOptimization duplicates this logic, merge. 243 // TODO(dcarney): CallOptimization duplicates this logic, merge.
244 Object* FunctionTemplateInfo::GetCompatibleReceiver(Isolate* isolate, 244 Handle<Object> FunctionTemplateInfo::GetCompatibleReceiver(
245 Object* receiver) { 245 Isolate* isolate, Handle<Object> receiver, bool is_construct) {
246 // API calls are only supported with JSObject receivers. 246 // API calls are only supported with JSObject receivers.
247 if (!receiver->IsJSObject()) return isolate->heap()->null_value(); 247 if (!receiver->IsJSObject()) return isolate->factory()->null_value();
248 auto js_receiver = Handle<JSObject>::cast(receiver);
249 if (!is_construct && js_receiver->IsAccessCheckNeeded() &&
250 !isolate->MayAccess(js_receiver)) {
Toon Verwaest 2015/03/25 15:28:24 This isn't good enough, as the IC you'll compile i
251 return isolate->factory()->null_value();
252 }
248 Object* recv_type = this->signature(); 253 Object* recv_type = this->signature();
249 // No signature, return holder. 254 // No signature, return holder.
250 if (recv_type->IsUndefined()) return receiver; 255 if (recv_type->IsUndefined()) return receiver;
251 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type); 256 FunctionTemplateInfo* signature = FunctionTemplateInfo::cast(recv_type);
252 // Check the receiver. 257 // Check the receiver.
253 for (PrototypeIterator iter(isolate, receiver, 258 for (PrototypeIterator iter(isolate, *receiver,
254 PrototypeIterator::START_AT_RECEIVER); 259 PrototypeIterator::START_AT_RECEIVER);
255 !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) { 260 !iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN); iter.Advance()) {
256 if (signature->IsTemplateFor(iter.GetCurrent())) return iter.GetCurrent(); 261 if (signature->IsTemplateFor(iter.GetCurrent())) {
262 return Handle<Object>(iter.GetCurrent(), isolate);
263 }
257 } 264 }
258 return isolate->heap()->null_value(); 265 return isolate->factory()->null_value();
259 } 266 }
260 267
261 268
262 Handle<FixedArray> JSObject::EnsureWritableFastElements( 269 Handle<FixedArray> JSObject::EnsureWritableFastElements(
263 Handle<JSObject> object) { 270 Handle<JSObject> object) {
264 DCHECK(object->HasFastSmiOrObjectElements()); 271 DCHECK(object->HasFastSmiOrObjectElements());
265 Isolate* isolate = object->GetIsolate(); 272 Isolate* isolate = object->GetIsolate();
266 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate); 273 Handle<FixedArray> elems(FixedArray::cast(object->elements()), isolate);
267 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems; 274 if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
268 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap( 275 Handle<FixedArray> writable_elems = isolate->factory()->CopyFixedArrayWithMap(
(...skipping 16847 matching lines...) Expand 10 before | Expand all | Expand 10 after
17116 CompilationInfo* info) { 17123 CompilationInfo* info) {
17117 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( 17124 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo(
17118 handle(cell->dependent_code(), info->isolate()), 17125 handle(cell->dependent_code(), info->isolate()),
17119 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); 17126 DependentCode::kPropertyCellChangedGroup, info->object_wrapper());
17120 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 17127 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
17121 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 17128 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
17122 cell, info->zone()); 17129 cell, info->zone());
17123 } 17130 }
17124 17131
17125 } } // namespace v8::internal 17132 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-accessors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698