OLD | NEW |
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 "src/deoptimizer.h" | 5 #include "src/deoptimizer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2274 // tagged value. kZapUint32 looks like a valid tagged pointer, but it isn't. | 2274 // tagged value. kZapUint32 looks like a valid tagged pointer, but it isn't. |
2275 SetRegister(r, kZapUint32); | 2275 SetRegister(r, kZapUint32); |
2276 } | 2276 } |
2277 | 2277 |
2278 // Zap all the slots. | 2278 // Zap all the slots. |
2279 for (unsigned o = 0; o < frame_size; o += kPointerSize) { | 2279 for (unsigned o = 0; o < frame_size; o += kPointerSize) { |
2280 SetFrameSlot(o, kZapUint32); | 2280 SetFrameSlot(o, kZapUint32); |
2281 } | 2281 } |
2282 } | 2282 } |
2283 | 2283 |
2284 void TranslationBuffer::Add(int32_t value, Zone* zone) { | 2284 void TranslationBuffer::Add(int32_t value) { |
2285 // This wouldn't handle kMinInt correctly if it ever encountered it. | 2285 // This wouldn't handle kMinInt correctly if it ever encountered it. |
2286 DCHECK(value != kMinInt); | 2286 DCHECK(value != kMinInt); |
2287 // Encode the sign bit in the least significant bit. | 2287 // Encode the sign bit in the least significant bit. |
2288 bool is_negative = (value < 0); | 2288 bool is_negative = (value < 0); |
2289 uint32_t bits = ((is_negative ? -value : value) << 1) | | 2289 uint32_t bits = ((is_negative ? -value : value) << 1) | |
2290 static_cast<int32_t>(is_negative); | 2290 static_cast<int32_t>(is_negative); |
2291 // Encode the individual bytes using the least significant bit of | 2291 // Encode the individual bytes using the least significant bit of |
2292 // each byte to indicate whether or not more bytes follow. | 2292 // each byte to indicate whether or not more bytes follow. |
2293 do { | 2293 do { |
2294 uint32_t next = bits >> 7; | 2294 uint32_t next = bits >> 7; |
2295 contents_.Add(((bits << 1) & 0xFF) | (next != 0), zone); | 2295 contents_.push_back(((bits << 1) & 0xFF) | (next != 0)); |
2296 bits = next; | 2296 bits = next; |
2297 } while (bits != 0); | 2297 } while (bits != 0); |
2298 } | 2298 } |
2299 | 2299 |
2300 | 2300 |
2301 int32_t TranslationIterator::Next() { | 2301 int32_t TranslationIterator::Next() { |
2302 // Run through the bytes until we reach one with a least significant | 2302 // Run through the bytes until we reach one with a least significant |
2303 // bit of zero (marks the end). | 2303 // bit of zero (marks the end). |
2304 uint32_t bits = 0; | 2304 uint32_t bits = 0; |
2305 for (int i = 0; true; i += 7) { | 2305 for (int i = 0; true; i += 7) { |
2306 DCHECK(HasNext()); | 2306 DCHECK(HasNext()); |
2307 uint8_t next = buffer_->get(index_++); | 2307 uint8_t next = buffer_->get(index_++); |
2308 bits |= (next >> 1) << i; | 2308 bits |= (next >> 1) << i; |
2309 if ((next & 1) == 0) break; | 2309 if ((next & 1) == 0) break; |
2310 } | 2310 } |
2311 // The bits encode the sign in the least significant bit. | 2311 // The bits encode the sign in the least significant bit. |
2312 bool is_negative = (bits & 1) == 1; | 2312 bool is_negative = (bits & 1) == 1; |
2313 int32_t result = bits >> 1; | 2313 int32_t result = bits >> 1; |
2314 return is_negative ? -result : result; | 2314 return is_negative ? -result : result; |
2315 } | 2315 } |
2316 | 2316 |
2317 | 2317 |
2318 Handle<ByteArray> TranslationBuffer::CreateByteArray(Factory* factory) { | 2318 Handle<ByteArray> TranslationBuffer::CreateByteArray(Factory* factory) { |
2319 int length = contents_.length(); | 2319 Handle<ByteArray> result = factory->NewByteArray(CurrentIndex(), TENURED); |
2320 Handle<ByteArray> result = factory->NewByteArray(length, TENURED); | 2320 contents_.CopyTo(result->GetDataStartAddress()); |
2321 MemCopy(result->GetDataStartAddress(), contents_.ToVector().start(), length); | |
2322 return result; | 2321 return result; |
2323 } | 2322 } |
2324 | 2323 |
2325 | 2324 |
2326 void Translation::BeginConstructStubFrame(int literal_id, unsigned height) { | 2325 void Translation::BeginConstructStubFrame(int literal_id, unsigned height) { |
2327 buffer_->Add(CONSTRUCT_STUB_FRAME, zone()); | 2326 buffer_->Add(CONSTRUCT_STUB_FRAME); |
2328 buffer_->Add(literal_id, zone()); | 2327 buffer_->Add(literal_id); |
2329 buffer_->Add(height, zone()); | 2328 buffer_->Add(height); |
2330 } | 2329 } |
2331 | 2330 |
2332 | 2331 |
2333 void Translation::BeginGetterStubFrame(int literal_id) { | 2332 void Translation::BeginGetterStubFrame(int literal_id) { |
2334 buffer_->Add(GETTER_STUB_FRAME, zone()); | 2333 buffer_->Add(GETTER_STUB_FRAME); |
2335 buffer_->Add(literal_id, zone()); | 2334 buffer_->Add(literal_id); |
2336 } | 2335 } |
2337 | 2336 |
2338 | 2337 |
2339 void Translation::BeginSetterStubFrame(int literal_id) { | 2338 void Translation::BeginSetterStubFrame(int literal_id) { |
2340 buffer_->Add(SETTER_STUB_FRAME, zone()); | 2339 buffer_->Add(SETTER_STUB_FRAME); |
2341 buffer_->Add(literal_id, zone()); | 2340 buffer_->Add(literal_id); |
2342 } | 2341 } |
2343 | 2342 |
2344 | 2343 |
2345 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { | 2344 void Translation::BeginArgumentsAdaptorFrame(int literal_id, unsigned height) { |
2346 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME, zone()); | 2345 buffer_->Add(ARGUMENTS_ADAPTOR_FRAME); |
2347 buffer_->Add(literal_id, zone()); | 2346 buffer_->Add(literal_id); |
2348 buffer_->Add(height, zone()); | 2347 buffer_->Add(height); |
2349 } | 2348 } |
2350 | 2349 |
2351 void Translation::BeginTailCallerFrame(int literal_id) { | 2350 void Translation::BeginTailCallerFrame(int literal_id) { |
2352 buffer_->Add(TAIL_CALLER_FRAME, zone()); | 2351 buffer_->Add(TAIL_CALLER_FRAME); |
2353 buffer_->Add(literal_id, zone()); | 2352 buffer_->Add(literal_id); |
2354 } | 2353 } |
2355 | 2354 |
2356 void Translation::BeginJSFrame(BailoutId node_id, | 2355 void Translation::BeginJSFrame(BailoutId node_id, |
2357 int literal_id, | 2356 int literal_id, |
2358 unsigned height) { | 2357 unsigned height) { |
2359 buffer_->Add(JS_FRAME, zone()); | 2358 buffer_->Add(JS_FRAME); |
2360 buffer_->Add(node_id.ToInt(), zone()); | 2359 buffer_->Add(node_id.ToInt()); |
2361 buffer_->Add(literal_id, zone()); | 2360 buffer_->Add(literal_id); |
2362 buffer_->Add(height, zone()); | 2361 buffer_->Add(height); |
2363 } | 2362 } |
2364 | 2363 |
2365 | 2364 |
2366 void Translation::BeginInterpretedFrame(BailoutId bytecode_offset, | 2365 void Translation::BeginInterpretedFrame(BailoutId bytecode_offset, |
2367 int literal_id, unsigned height) { | 2366 int literal_id, unsigned height) { |
2368 buffer_->Add(INTERPRETED_FRAME, zone()); | 2367 buffer_->Add(INTERPRETED_FRAME); |
2369 buffer_->Add(bytecode_offset.ToInt(), zone()); | 2368 buffer_->Add(bytecode_offset.ToInt()); |
2370 buffer_->Add(literal_id, zone()); | 2369 buffer_->Add(literal_id); |
2371 buffer_->Add(height, zone()); | 2370 buffer_->Add(height); |
2372 } | 2371 } |
2373 | 2372 |
2374 | 2373 |
2375 void Translation::BeginCompiledStubFrame(int height) { | 2374 void Translation::BeginCompiledStubFrame(int height) { |
2376 buffer_->Add(COMPILED_STUB_FRAME, zone()); | 2375 buffer_->Add(COMPILED_STUB_FRAME); |
2377 buffer_->Add(height, zone()); | 2376 buffer_->Add(height); |
2378 } | 2377 } |
2379 | 2378 |
2380 | 2379 |
2381 void Translation::BeginArgumentsObject(int args_length) { | 2380 void Translation::BeginArgumentsObject(int args_length) { |
2382 buffer_->Add(ARGUMENTS_OBJECT, zone()); | 2381 buffer_->Add(ARGUMENTS_OBJECT); |
2383 buffer_->Add(args_length, zone()); | 2382 buffer_->Add(args_length); |
2384 } | 2383 } |
2385 | 2384 |
2386 | 2385 |
2387 void Translation::BeginCapturedObject(int length) { | 2386 void Translation::BeginCapturedObject(int length) { |
2388 buffer_->Add(CAPTURED_OBJECT, zone()); | 2387 buffer_->Add(CAPTURED_OBJECT); |
2389 buffer_->Add(length, zone()); | 2388 buffer_->Add(length); |
2390 } | 2389 } |
2391 | 2390 |
2392 | 2391 |
2393 void Translation::DuplicateObject(int object_index) { | 2392 void Translation::DuplicateObject(int object_index) { |
2394 buffer_->Add(DUPLICATED_OBJECT, zone()); | 2393 buffer_->Add(DUPLICATED_OBJECT); |
2395 buffer_->Add(object_index, zone()); | 2394 buffer_->Add(object_index); |
2396 } | 2395 } |
2397 | 2396 |
2398 | 2397 |
2399 void Translation::StoreRegister(Register reg) { | 2398 void Translation::StoreRegister(Register reg) { |
2400 buffer_->Add(REGISTER, zone()); | 2399 buffer_->Add(REGISTER); |
2401 buffer_->Add(reg.code(), zone()); | 2400 buffer_->Add(reg.code()); |
2402 } | 2401 } |
2403 | 2402 |
2404 | 2403 |
2405 void Translation::StoreInt32Register(Register reg) { | 2404 void Translation::StoreInt32Register(Register reg) { |
2406 buffer_->Add(INT32_REGISTER, zone()); | 2405 buffer_->Add(INT32_REGISTER); |
2407 buffer_->Add(reg.code(), zone()); | 2406 buffer_->Add(reg.code()); |
2408 } | 2407 } |
2409 | 2408 |
2410 | 2409 |
2411 void Translation::StoreUint32Register(Register reg) { | 2410 void Translation::StoreUint32Register(Register reg) { |
2412 buffer_->Add(UINT32_REGISTER, zone()); | 2411 buffer_->Add(UINT32_REGISTER); |
2413 buffer_->Add(reg.code(), zone()); | 2412 buffer_->Add(reg.code()); |
2414 } | 2413 } |
2415 | 2414 |
2416 | 2415 |
2417 void Translation::StoreBoolRegister(Register reg) { | 2416 void Translation::StoreBoolRegister(Register reg) { |
2418 buffer_->Add(BOOL_REGISTER, zone()); | 2417 buffer_->Add(BOOL_REGISTER); |
2419 buffer_->Add(reg.code(), zone()); | 2418 buffer_->Add(reg.code()); |
2420 } | 2419 } |
2421 | 2420 |
2422 void Translation::StoreFloatRegister(FloatRegister reg) { | 2421 void Translation::StoreFloatRegister(FloatRegister reg) { |
2423 buffer_->Add(FLOAT_REGISTER, zone()); | 2422 buffer_->Add(FLOAT_REGISTER); |
2424 buffer_->Add(reg.code(), zone()); | 2423 buffer_->Add(reg.code()); |
2425 } | 2424 } |
2426 | 2425 |
2427 void Translation::StoreDoubleRegister(DoubleRegister reg) { | 2426 void Translation::StoreDoubleRegister(DoubleRegister reg) { |
2428 buffer_->Add(DOUBLE_REGISTER, zone()); | 2427 buffer_->Add(DOUBLE_REGISTER); |
2429 buffer_->Add(reg.code(), zone()); | 2428 buffer_->Add(reg.code()); |
2430 } | 2429 } |
2431 | 2430 |
2432 | 2431 |
2433 void Translation::StoreStackSlot(int index) { | 2432 void Translation::StoreStackSlot(int index) { |
2434 buffer_->Add(STACK_SLOT, zone()); | 2433 buffer_->Add(STACK_SLOT); |
2435 buffer_->Add(index, zone()); | 2434 buffer_->Add(index); |
2436 } | 2435 } |
2437 | 2436 |
2438 | 2437 |
2439 void Translation::StoreInt32StackSlot(int index) { | 2438 void Translation::StoreInt32StackSlot(int index) { |
2440 buffer_->Add(INT32_STACK_SLOT, zone()); | 2439 buffer_->Add(INT32_STACK_SLOT); |
2441 buffer_->Add(index, zone()); | 2440 buffer_->Add(index); |
2442 } | 2441 } |
2443 | 2442 |
2444 | 2443 |
2445 void Translation::StoreUint32StackSlot(int index) { | 2444 void Translation::StoreUint32StackSlot(int index) { |
2446 buffer_->Add(UINT32_STACK_SLOT, zone()); | 2445 buffer_->Add(UINT32_STACK_SLOT); |
2447 buffer_->Add(index, zone()); | 2446 buffer_->Add(index); |
2448 } | 2447 } |
2449 | 2448 |
2450 | 2449 |
2451 void Translation::StoreBoolStackSlot(int index) { | 2450 void Translation::StoreBoolStackSlot(int index) { |
2452 buffer_->Add(BOOL_STACK_SLOT, zone()); | 2451 buffer_->Add(BOOL_STACK_SLOT); |
2453 buffer_->Add(index, zone()); | 2452 buffer_->Add(index); |
2454 } | 2453 } |
2455 | 2454 |
2456 void Translation::StoreFloatStackSlot(int index) { | 2455 void Translation::StoreFloatStackSlot(int index) { |
2457 buffer_->Add(FLOAT_STACK_SLOT, zone()); | 2456 buffer_->Add(FLOAT_STACK_SLOT); |
2458 buffer_->Add(index, zone()); | 2457 buffer_->Add(index); |
2459 } | 2458 } |
2460 | 2459 |
2461 void Translation::StoreDoubleStackSlot(int index) { | 2460 void Translation::StoreDoubleStackSlot(int index) { |
2462 buffer_->Add(DOUBLE_STACK_SLOT, zone()); | 2461 buffer_->Add(DOUBLE_STACK_SLOT); |
2463 buffer_->Add(index, zone()); | 2462 buffer_->Add(index); |
2464 } | 2463 } |
2465 | 2464 |
2466 | 2465 |
2467 void Translation::StoreLiteral(int literal_id) { | 2466 void Translation::StoreLiteral(int literal_id) { |
2468 buffer_->Add(LITERAL, zone()); | 2467 buffer_->Add(LITERAL); |
2469 buffer_->Add(literal_id, zone()); | 2468 buffer_->Add(literal_id); |
2470 } | 2469 } |
2471 | 2470 |
2472 | 2471 |
2473 void Translation::StoreArgumentsObject(bool args_known, | 2472 void Translation::StoreArgumentsObject(bool args_known, |
2474 int args_index, | 2473 int args_index, |
2475 int args_length) { | 2474 int args_length) { |
2476 buffer_->Add(ARGUMENTS_OBJECT, zone()); | 2475 buffer_->Add(ARGUMENTS_OBJECT); |
2477 buffer_->Add(args_known, zone()); | 2476 buffer_->Add(args_known); |
2478 buffer_->Add(args_index, zone()); | 2477 buffer_->Add(args_index); |
2479 buffer_->Add(args_length, zone()); | 2478 buffer_->Add(args_length); |
2480 } | 2479 } |
2481 | 2480 |
2482 | 2481 |
2483 void Translation::StoreJSFrameFunction() { | 2482 void Translation::StoreJSFrameFunction() { |
2484 StoreStackSlot((StandardFrameConstants::kCallerPCOffset - | 2483 StoreStackSlot((StandardFrameConstants::kCallerPCOffset - |
2485 StandardFrameConstants::kFunctionOffset) / | 2484 StandardFrameConstants::kFunctionOffset) / |
2486 kPointerSize); | 2485 kPointerSize); |
2487 } | 2486 } |
2488 | 2487 |
2489 int Translation::NumberOfOperandsFor(Opcode opcode) { | 2488 int Translation::NumberOfOperandsFor(Opcode opcode) { |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4012 CHECK(value_info->IsMaterializedObject()); | 4011 CHECK(value_info->IsMaterializedObject()); |
4013 | 4012 |
4014 value_info->value_ = | 4013 value_info->value_ = |
4015 Handle<Object>(previously_materialized_objects->get(i), isolate_); | 4014 Handle<Object>(previously_materialized_objects->get(i), isolate_); |
4016 } | 4015 } |
4017 } | 4016 } |
4018 } | 4017 } |
4019 | 4018 |
4020 } // namespace internal | 4019 } // namespace internal |
4021 } // namespace v8 | 4020 } // namespace v8 |
OLD | NEW |