| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2298 Comment cmnt(masm_, "[ DebuggerStatament"); | 2298 Comment cmnt(masm_, "[ DebuggerStatament"); |
| 2299 CodeForStatementPosition(node); | 2299 CodeForStatementPosition(node); |
| 2300 #ifdef ENABLE_DEBUGGER_SUPPORT | 2300 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 2301 frame_->DebugBreak(); | 2301 frame_->DebugBreak(); |
| 2302 #endif | 2302 #endif |
| 2303 // Ignore the return value. | 2303 // Ignore the return value. |
| 2304 ASSERT(frame_->height() == original_height); | 2304 ASSERT(frame_->height() == original_height); |
| 2305 } | 2305 } |
| 2306 | 2306 |
| 2307 | 2307 |
| 2308 void CodeGenerator::InstantiateBoilerplate(Handle<JSFunction> boilerplate) { | 2308 void CodeGenerator::InstantiateFunction( |
| 2309 Handle<SharedFunctionInfo> function_info) { |
| 2309 VirtualFrame::SpilledScope spilled_scope; | 2310 VirtualFrame::SpilledScope spilled_scope; |
| 2310 ASSERT(boilerplate->IsBoilerplate()); | 2311 __ mov(r0, Operand(function_info)); |
| 2311 | |
| 2312 __ mov(r0, Operand(boilerplate)); | |
| 2313 // Use the fast case closure allocation code that allocates in new | 2312 // Use the fast case closure allocation code that allocates in new |
| 2314 // space for nested functions that don't need literals cloning. | 2313 // space for nested functions that don't need literals cloning. |
| 2315 if (scope()->is_function_scope() && boilerplate->NumberOfLiterals() == 0) { | 2314 if (scope()->is_function_scope() && function_info->num_literals() == 0) { |
| 2316 FastNewClosureStub stub; | 2315 FastNewClosureStub stub; |
| 2317 frame_->EmitPush(r0); | 2316 frame_->EmitPush(r0); |
| 2318 frame_->CallStub(&stub, 1); | 2317 frame_->CallStub(&stub, 1); |
| 2319 frame_->EmitPush(r0); | 2318 frame_->EmitPush(r0); |
| 2320 } else { | 2319 } else { |
| 2321 // Create a new closure. | 2320 // Create a new closure. |
| 2322 frame_->EmitPush(cp); | 2321 frame_->EmitPush(cp); |
| 2323 frame_->EmitPush(r0); | 2322 frame_->EmitPush(r0); |
| 2324 frame_->CallRuntime(Runtime::kNewClosure, 2); | 2323 frame_->CallRuntime(Runtime::kNewClosure, 2); |
| 2325 frame_->EmitPush(r0); | 2324 frame_->EmitPush(r0); |
| 2326 } | 2325 } |
| 2327 } | 2326 } |
| 2328 | 2327 |
| 2329 | 2328 |
| 2330 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { | 2329 void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) { |
| 2331 #ifdef DEBUG | 2330 #ifdef DEBUG |
| 2332 int original_height = frame_->height(); | 2331 int original_height = frame_->height(); |
| 2333 #endif | 2332 #endif |
| 2334 VirtualFrame::SpilledScope spilled_scope; | 2333 VirtualFrame::SpilledScope spilled_scope; |
| 2335 Comment cmnt(masm_, "[ FunctionLiteral"); | 2334 Comment cmnt(masm_, "[ FunctionLiteral"); |
| 2336 | 2335 |
| 2337 // Build the function boilerplate and instantiate it. | 2336 // Build the function info and instantiate it. |
| 2338 Handle<JSFunction> boilerplate = | 2337 Handle<SharedFunctionInfo> function_info = |
| 2339 Compiler::BuildBoilerplate(node, script(), this); | 2338 Compiler::BuildFunctionInfo(node, script(), this); |
| 2340 // Check for stack-overflow exception. | 2339 // Check for stack-overflow exception. |
| 2341 if (HasStackOverflow()) { | 2340 if (HasStackOverflow()) { |
| 2342 ASSERT(frame_->height() == original_height); | 2341 ASSERT(frame_->height() == original_height); |
| 2343 return; | 2342 return; |
| 2344 } | 2343 } |
| 2345 InstantiateBoilerplate(boilerplate); | 2344 InstantiateFunction(function_info); |
| 2346 ASSERT(frame_->height() == original_height + 1); | 2345 ASSERT(frame_->height() == original_height + 1); |
| 2347 } | 2346 } |
| 2348 | 2347 |
| 2349 | 2348 |
| 2350 void CodeGenerator::VisitFunctionBoilerplateLiteral( | 2349 void CodeGenerator::VisitSharedFunctionInfoLiteral( |
| 2351 FunctionBoilerplateLiteral* node) { | 2350 SharedFunctionInfoLiteral* node) { |
| 2352 #ifdef DEBUG | 2351 #ifdef DEBUG |
| 2353 int original_height = frame_->height(); | 2352 int original_height = frame_->height(); |
| 2354 #endif | 2353 #endif |
| 2355 VirtualFrame::SpilledScope spilled_scope; | 2354 VirtualFrame::SpilledScope spilled_scope; |
| 2356 Comment cmnt(masm_, "[ FunctionBoilerplateLiteral"); | 2355 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); |
| 2357 InstantiateBoilerplate(node->boilerplate()); | 2356 InstantiateFunction(node->shared_function_info()); |
| 2358 ASSERT(frame_->height() == original_height + 1); | 2357 ASSERT(frame_->height() == original_height + 1); |
| 2359 } | 2358 } |
| 2360 | 2359 |
| 2361 | 2360 |
| 2362 void CodeGenerator::VisitConditional(Conditional* node) { | 2361 void CodeGenerator::VisitConditional(Conditional* node) { |
| 2363 #ifdef DEBUG | 2362 #ifdef DEBUG |
| 2364 int original_height = frame_->height(); | 2363 int original_height = frame_->height(); |
| 2365 #endif | 2364 #endif |
| 2366 VirtualFrame::SpilledScope spilled_scope; | 2365 VirtualFrame::SpilledScope spilled_scope; |
| 2367 Comment cmnt(masm_, "[ Conditional"); | 2366 Comment cmnt(masm_, "[ Conditional"); |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4520 break; | 4519 break; |
| 4521 } | 4520 } |
| 4522 | 4521 |
| 4523 default: | 4522 default: |
| 4524 UNREACHABLE(); | 4523 UNREACHABLE(); |
| 4525 } | 4524 } |
| 4526 } | 4525 } |
| 4527 | 4526 |
| 4528 | 4527 |
| 4529 void FastNewClosureStub::Generate(MacroAssembler* masm) { | 4528 void FastNewClosureStub::Generate(MacroAssembler* masm) { |
| 4530 // Clone the boilerplate in new space. Set the context to the | 4529 // Create a new closure from the given function info in new |
| 4531 // current context in cp. | 4530 // space. Set the context to the current context in cp. |
| 4532 Label gc; | 4531 Label gc; |
| 4533 | 4532 |
| 4534 // Pop the boilerplate function from the stack. | 4533 // Pop the function info from the stack. |
| 4535 __ pop(r3); | 4534 __ pop(r3); |
| 4536 | 4535 |
| 4537 // Attempt to allocate new JSFunction in new space. | 4536 // Attempt to allocate new JSFunction in new space. |
| 4538 __ AllocateInNewSpace(JSFunction::kSize / kPointerSize, | 4537 __ AllocateInNewSpace(JSFunction::kSize / kPointerSize, |
| 4539 r0, | 4538 r0, |
| 4540 r1, | 4539 r1, |
| 4541 r2, | 4540 r2, |
| 4542 &gc, | 4541 &gc, |
| 4543 TAG_OBJECT); | 4542 TAG_OBJECT); |
| 4544 | 4543 |
| 4545 // Compute the function map in the current global context and set that | 4544 // Compute the function map in the current global context and set that |
| 4546 // as the map of the allocated object. | 4545 // as the map of the allocated object. |
| 4547 __ ldr(r2, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); | 4546 __ ldr(r2, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 4548 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); | 4547 __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalContextOffset)); |
| 4549 __ ldr(r2, MemOperand(r2, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); | 4548 __ ldr(r2, MemOperand(r2, Context::SlotOffset(Context::FUNCTION_MAP_INDEX))); |
| 4550 __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); | 4549 __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4551 | 4550 |
| 4552 // Clone the rest of the boilerplate fields. We don't have to update | 4551 // Initialize the rest of the function. We don't have to update the |
| 4553 // the write barrier because the allocated object is in new space. | 4552 // write barrier because the allocated object is in new space. |
| 4554 for (int offset = kPointerSize; | 4553 __ LoadRoot(r1, Heap::kEmptyFixedArrayRootIndex); |
| 4555 offset < JSFunction::kSize; | 4554 __ LoadRoot(r2, Heap::kTheHoleValueRootIndex); |
| 4556 offset += kPointerSize) { | 4555 __ str(r1, FieldMemOperand(r0, JSObject::kPropertiesOffset)); |
| 4557 if (offset == JSFunction::kContextOffset) { | 4556 __ str(r1, FieldMemOperand(r0, JSObject::kElementsOffset)); |
| 4558 __ str(cp, FieldMemOperand(r0, offset)); | 4557 __ str(r2, FieldMemOperand(r0, JSFunction::kPrototypeOrInitialMapOffset)); |
| 4559 } else { | 4558 __ str(r3, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); |
| 4560 __ ldr(r1, FieldMemOperand(r3, offset)); | 4559 __ str(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); |
| 4561 __ str(r1, FieldMemOperand(r0, offset)); | 4560 __ str(r1, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); |
| 4562 } | |
| 4563 } | |
| 4564 | 4561 |
| 4565 // Return result. The argument boilerplate has been popped already. | 4562 // Return result. The argument function info has been popped already. |
| 4566 __ Ret(); | 4563 __ Ret(); |
| 4567 | 4564 |
| 4568 // Create a new closure through the slower runtime call. | 4565 // Create a new closure through the slower runtime call. |
| 4569 __ bind(&gc); | 4566 __ bind(&gc); |
| 4570 __ push(cp); | 4567 __ push(cp); |
| 4571 __ push(r3); | 4568 __ push(r3); |
| 4572 __ TailCallRuntime(Runtime::kNewClosure, 2, 1); | 4569 __ TailCallRuntime(Runtime::kNewClosure, 2, 1); |
| 4573 } | 4570 } |
| 4574 | 4571 |
| 4575 | 4572 |
| (...skipping 2576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7152 return "CompareStub_EQ"; | 7149 return "CompareStub_EQ"; |
| 7153 } | 7150 } |
| 7154 } | 7151 } |
| 7155 } | 7152 } |
| 7156 default: return "CompareStub"; | 7153 default: return "CompareStub"; |
| 7157 } | 7154 } |
| 7158 } | 7155 } |
| 7159 | 7156 |
| 7160 | 7157 |
| 7161 int CompareStub::MinorKey() { | 7158 int CompareStub::MinorKey() { |
| 7162 // Encode the three parameters in a unique 16 bit value. | 7159 // Encode the three parameters in a unique 16 bit value. To avoid duplicate |
| 7163 ASSERT((static_cast<unsigned>(cc_) >> 26) < (1 << 16)); | 7160 // stubs the never NaN NaN condition is only taken into account if the |
| 7164 int nnn_value = (never_nan_nan_ ? 2 : 0); | 7161 // condition is equals. |
| 7165 if (cc_ != eq) nnn_value = 0; // Avoid duplicate stubs. | 7162 ASSERT((static_cast<unsigned>(cc_) >> 28) < (1 << 14)); |
| 7166 return (static_cast<unsigned>(cc_) >> 26) | nnn_value | (strict_ ? 1 : 0); | 7163 return ConditionField::encode(static_cast<unsigned>(cc_) >> 28) |
| 7164 | StrictField::encode(strict_) |
| 7165 | NeverNanNanField::encode(cc_ == eq ? never_nan_nan_ : false); |
| 7167 } | 7166 } |
| 7168 | 7167 |
| 7169 | 7168 |
| 7170 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, | 7169 void StringStubBase::GenerateCopyCharacters(MacroAssembler* masm, |
| 7171 Register dest, | 7170 Register dest, |
| 7172 Register src, | 7171 Register src, |
| 7173 Register count, | 7172 Register count, |
| 7174 Register scratch, | 7173 Register scratch, |
| 7175 bool ascii) { | 7174 bool ascii) { |
| 7176 Label loop; | 7175 Label loop; |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8042 | 8041 |
| 8043 // Just jump to runtime to add the two strings. | 8042 // Just jump to runtime to add the two strings. |
| 8044 __ bind(&string_add_runtime); | 8043 __ bind(&string_add_runtime); |
| 8045 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); | 8044 __ TailCallRuntime(Runtime::kStringAdd, 2, 1); |
| 8046 } | 8045 } |
| 8047 | 8046 |
| 8048 | 8047 |
| 8049 #undef __ | 8048 #undef __ |
| 8050 | 8049 |
| 8051 } } // namespace v8::internal | 8050 } } // namespace v8::internal |
| OLD | NEW |