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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 14403015: Disallow dereferencing deferred handles when generating optimized code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 years, 8 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 | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.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 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 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 2279
2280 2280
2281 void MacroAssembler::Move(Register dst, Register src) { 2281 void MacroAssembler::Move(Register dst, Register src) {
2282 if (!dst.is(src)) { 2282 if (!dst.is(src)) {
2283 movq(dst, src); 2283 movq(dst, src);
2284 } 2284 }
2285 } 2285 }
2286 2286
2287 2287
2288 void MacroAssembler::Move(Register dst, Handle<Object> source) { 2288 void MacroAssembler::Move(Register dst, Handle<Object> source) {
2289 ASSERT(!source->IsFailure()); 2289 ALLOW_HANDLE_DEREF(isolate(), "smi check");
2290 if (source->IsSmi()) { 2290 if (source->IsSmi()) {
2291 Move(dst, Smi::cast(*source)); 2291 Move(dst, Smi::cast(*source));
2292 } else { 2292 } else {
2293 movq(dst, source, RelocInfo::EMBEDDED_OBJECT); 2293 movq(dst, source, RelocInfo::EMBEDDED_OBJECT);
2294 } 2294 }
2295 } 2295 }
2296 2296
2297 2297
2298 void MacroAssembler::Move(const Operand& dst, Handle<Object> source) { 2298 void MacroAssembler::Move(const Operand& dst, Handle<Object> source) {
2299 ASSERT(!source->IsFailure()); 2299 ALLOW_HANDLE_DEREF(isolate(), "smi check");
2300 if (source->IsSmi()) { 2300 if (source->IsSmi()) {
2301 Move(dst, Smi::cast(*source)); 2301 Move(dst, Smi::cast(*source));
2302 } else { 2302 } else {
2303 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); 2303 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2304 movq(dst, kScratchRegister); 2304 movq(dst, kScratchRegister);
2305 } 2305 }
2306 } 2306 }
2307 2307
2308 2308
2309 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { 2309 void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
2310 ALLOW_HANDLE_DEREF(isolate(), "smi check");
2310 if (source->IsSmi()) { 2311 if (source->IsSmi()) {
2311 Cmp(dst, Smi::cast(*source)); 2312 Cmp(dst, Smi::cast(*source));
2312 } else { 2313 } else {
2313 Move(kScratchRegister, source); 2314 Move(kScratchRegister, source);
2314 cmpq(dst, kScratchRegister); 2315 cmpq(dst, kScratchRegister);
2315 } 2316 }
2316 } 2317 }
2317 2318
2318 2319
2319 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) { 2320 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) {
2321 ALLOW_HANDLE_DEREF(isolate(), "smi check");
2320 if (source->IsSmi()) { 2322 if (source->IsSmi()) {
2321 Cmp(dst, Smi::cast(*source)); 2323 Cmp(dst, Smi::cast(*source));
2322 } else { 2324 } else {
2323 ASSERT(source->IsHeapObject()); 2325 ASSERT(source->IsHeapObject());
2324 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); 2326 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2325 cmpq(dst, kScratchRegister); 2327 cmpq(dst, kScratchRegister);
2326 } 2328 }
2327 } 2329 }
2328 2330
2329 2331
2330 void MacroAssembler::Push(Handle<Object> source) { 2332 void MacroAssembler::Push(Handle<Object> source) {
2333 ALLOW_HANDLE_DEREF(isolate(), "smi check");
2331 if (source->IsSmi()) { 2334 if (source->IsSmi()) {
2332 Push(Smi::cast(*source)); 2335 Push(Smi::cast(*source));
2333 } else { 2336 } else {
2334 ASSERT(source->IsHeapObject()); 2337 ASSERT(source->IsHeapObject());
2335 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT); 2338 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2336 push(kScratchRegister); 2339 push(kScratchRegister);
2337 } 2340 }
2338 } 2341 }
2339 2342
2340 2343
2341 void MacroAssembler::LoadHeapObject(Register result, 2344 void MacroAssembler::LoadHeapObject(Register result,
2342 Handle<HeapObject> object) { 2345 Handle<HeapObject> object) {
2346 ALLOW_HANDLE_DEREF(isolate(), "using raw address");
2343 if (isolate()->heap()->InNewSpace(*object)) { 2347 if (isolate()->heap()->InNewSpace(*object)) {
2344 Handle<JSGlobalPropertyCell> cell = 2348 Handle<JSGlobalPropertyCell> cell =
2345 isolate()->factory()->NewJSGlobalPropertyCell(object); 2349 isolate()->factory()->NewJSGlobalPropertyCell(object);
2346 movq(result, cell, RelocInfo::GLOBAL_PROPERTY_CELL); 2350 movq(result, cell, RelocInfo::GLOBAL_PROPERTY_CELL);
2347 movq(result, Operand(result, 0)); 2351 movq(result, Operand(result, 0));
2348 } else { 2352 } else {
2349 Move(result, object); 2353 Move(result, object);
2350 } 2354 }
2351 } 2355 }
2352 2356
2353 2357
2354 void MacroAssembler::PushHeapObject(Handle<HeapObject> object) { 2358 void MacroAssembler::PushHeapObject(Handle<HeapObject> object) {
2359 ALLOW_HANDLE_DEREF(isolate(), "using raw address");
2355 if (isolate()->heap()->InNewSpace(*object)) { 2360 if (isolate()->heap()->InNewSpace(*object)) {
2356 Handle<JSGlobalPropertyCell> cell = 2361 Handle<JSGlobalPropertyCell> cell =
2357 isolate()->factory()->NewJSGlobalPropertyCell(object); 2362 isolate()->factory()->NewJSGlobalPropertyCell(object);
2358 movq(kScratchRegister, cell, RelocInfo::GLOBAL_PROPERTY_CELL); 2363 movq(kScratchRegister, cell, RelocInfo::GLOBAL_PROPERTY_CELL);
2359 movq(kScratchRegister, Operand(kScratchRegister, 0)); 2364 movq(kScratchRegister, Operand(kScratchRegister, 0));
2360 push(kScratchRegister); 2365 push(kScratchRegister);
2361 } else { 2366 } else {
2362 Push(object); 2367 Push(object);
2363 } 2368 }
2364 } 2369 }
2365 2370
2366 2371
2367 void MacroAssembler::LoadGlobalCell(Register dst, 2372 void MacroAssembler::LoadGlobalCell(Register dst,
2368 Handle<JSGlobalPropertyCell> cell) { 2373 Handle<JSGlobalPropertyCell> cell) {
2369 if (dst.is(rax)) { 2374 if (dst.is(rax)) {
2375 ALLOW_HANDLE_DEREF(isolate(), "embedding raw address");
2370 load_rax(cell.location(), RelocInfo::GLOBAL_PROPERTY_CELL); 2376 load_rax(cell.location(), RelocInfo::GLOBAL_PROPERTY_CELL);
2371 } else { 2377 } else {
2372 movq(dst, cell, RelocInfo::GLOBAL_PROPERTY_CELL); 2378 movq(dst, cell, RelocInfo::GLOBAL_PROPERTY_CELL);
2373 movq(dst, Operand(dst, 0)); 2379 movq(dst, Operand(dst, 0));
2374 } 2380 }
2375 } 2381 }
2376 2382
2377 2383
2378 void MacroAssembler::Push(Smi* source) { 2384 void MacroAssembler::Push(Smi* source) {
2379 intptr_t smi = reinterpret_cast<intptr_t>(source); 2385 intptr_t smi = reinterpret_cast<intptr_t>(source);
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 // Advances rdx to the end of the Code object header, to the start of 3279 // Advances rdx to the end of the Code object header, to the start of
3274 // the executable code. 3280 // the executable code.
3275 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3281 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3276 3282
3277 ParameterCount expected(rbx); 3283 ParameterCount expected(rbx);
3278 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3284 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3279 } 3285 }
3280 3286
3281 3287
3282 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 3288 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
3289 const ParameterCount& expected,
3283 const ParameterCount& actual, 3290 const ParameterCount& actual,
3284 InvokeFlag flag, 3291 InvokeFlag flag,
3285 const CallWrapper& call_wrapper, 3292 const CallWrapper& call_wrapper,
3286 CallKind call_kind) { 3293 CallKind call_kind) {
3287 // You can't call a function without a valid frame. 3294 // You can't call a function without a valid frame.
3288 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3295 ASSERT(flag == JUMP_FUNCTION || has_frame());
3289 3296
3290 // Get the function and setup the context. 3297 // Get the function and setup the context.
3291 LoadHeapObject(rdi, function); 3298 LoadHeapObject(rdi, function);
3292 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 3299 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
3293 3300
3294 // We call indirectly through the code field in the function to 3301 // We call indirectly through the code field in the function to
3295 // allow recompilation to take effect without changing any of the 3302 // allow recompilation to take effect without changing any of the
3296 // call sites. 3303 // call sites.
3297 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3304 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3298 ParameterCount expected(function->shared()->formal_parameter_count());
3299 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3305 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3300 } 3306 }
3301 3307
3302 3308
3303 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 3309 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
3304 const ParameterCount& actual, 3310 const ParameterCount& actual,
3305 Handle<Code> code_constant, 3311 Handle<Code> code_constant,
3306 Register code_register, 3312 Register code_register,
3307 Label* done, 3313 Label* done,
3308 bool* definitely_mismatches, 3314 bool* definitely_mismatches,
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
4631 j(greater, &no_info_available); 4637 j(greater, &no_info_available);
4632 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize), 4638 CompareRoot(MemOperand(scratch_reg, -AllocationSiteInfo::kSize),
4633 Heap::kAllocationSiteInfoMapRootIndex); 4639 Heap::kAllocationSiteInfoMapRootIndex);
4634 bind(&no_info_available); 4640 bind(&no_info_available);
4635 } 4641 }
4636 4642
4637 4643
4638 } } // namespace v8::internal 4644 } } // namespace v8::internal
4639 4645
4640 #endif // V8_TARGET_ARCH_X64 4646 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698