| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/code-stubs.h" | 5 #include "src/code-stubs.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2323 { | 2323 { |
| 2324 var_result.Bind( | 2324 var_result.Bind( |
| 2325 assembler.CallRuntime(Runtime::kGetProperty, context, object, key)); | 2325 assembler.CallRuntime(Runtime::kGetProperty, context, object, key)); |
| 2326 assembler.Goto(&end); | 2326 assembler.Goto(&end); |
| 2327 } | 2327 } |
| 2328 | 2328 |
| 2329 assembler.Bind(&end); | 2329 assembler.Bind(&end); |
| 2330 assembler.Return(var_result.value()); | 2330 assembler.Return(var_result.value()); |
| 2331 } | 2331 } |
| 2332 | 2332 |
| 2333 | |
| 2334 // static | |
| 2335 int FastNewFunctionContextStub::MaximumSlots() { | |
| 2336 return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots | |
| 2337 : kMaximumSlots; | |
| 2338 } | |
| 2339 | |
| 2340 // static | |
| 2341 compiler::Node* FastNewFunctionContextStub::Generate( | |
| 2342 CodeStubAssembler* assembler, compiler::Node* function, | |
| 2343 compiler::Node* slots, compiler::Node* context, ScopeType scope_type) { | |
| 2344 typedef compiler::Node Node; | |
| 2345 | |
| 2346 slots = assembler->ChangeUint32ToWord(slots); | |
| 2347 | |
| 2348 // TODO(ishell): Use CSA::OptimalParameterMode() here. | |
| 2349 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; | |
| 2350 Node* min_context_slots = | |
| 2351 assembler->IntPtrConstant(Context::MIN_CONTEXT_SLOTS); | |
| 2352 Node* length = assembler->IntPtrAdd(slots, min_context_slots); | |
| 2353 Node* size = | |
| 2354 assembler->GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode); | |
| 2355 | |
| 2356 // Create a new closure from the given function info in new space | |
| 2357 Node* function_context = assembler->Allocate(size); | |
| 2358 | |
| 2359 Heap::RootListIndex context_type; | |
| 2360 switch (scope_type) { | |
| 2361 case EVAL_SCOPE: | |
| 2362 context_type = Heap::kEvalContextMapRootIndex; | |
| 2363 break; | |
| 2364 case FUNCTION_SCOPE: | |
| 2365 context_type = Heap::kFunctionContextMapRootIndex; | |
| 2366 break; | |
| 2367 default: | |
| 2368 UNREACHABLE(); | |
| 2369 } | |
| 2370 assembler->StoreMapNoWriteBarrier(function_context, context_type); | |
| 2371 assembler->StoreObjectFieldNoWriteBarrier( | |
| 2372 function_context, Context::kLengthOffset, assembler->SmiTag(length)); | |
| 2373 | |
| 2374 // Set up the fixed slots. | |
| 2375 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX, | |
| 2376 function, SKIP_WRITE_BARRIER); | |
| 2377 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX, | |
| 2378 context, SKIP_WRITE_BARRIER); | |
| 2379 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX, | |
| 2380 assembler->TheHoleConstant(), | |
| 2381 SKIP_WRITE_BARRIER); | |
| 2382 | |
| 2383 // Copy the native context from the previous context. | |
| 2384 Node* native_context = assembler->LoadNativeContext(context); | |
| 2385 assembler->StoreFixedArrayElement(function_context, | |
| 2386 Context::NATIVE_CONTEXT_INDEX, | |
| 2387 native_context, SKIP_WRITE_BARRIER); | |
| 2388 | |
| 2389 // Initialize the rest of the slots to undefined. | |
| 2390 Node* undefined = assembler->UndefinedConstant(); | |
| 2391 assembler->BuildFastFixedArrayForEach( | |
| 2392 function_context, FAST_ELEMENTS, min_context_slots, length, | |
| 2393 [assembler, undefined](Node* context, Node* offset) { | |
| 2394 assembler->StoreNoWriteBarrier(MachineRepresentation::kTagged, context, | |
| 2395 offset, undefined); | |
| 2396 }, | |
| 2397 mode); | |
| 2398 | |
| 2399 return function_context; | |
| 2400 } | |
| 2401 | |
| 2402 void FastNewFunctionContextStub::GenerateAssembly( | |
| 2403 compiler::CodeAssemblerState* state) const { | |
| 2404 typedef compiler::Node Node; | |
| 2405 CodeStubAssembler assembler(state); | |
| 2406 Node* function = assembler.Parameter(Descriptor::kFunction); | |
| 2407 Node* slots = assembler.Parameter(Descriptor::kSlots); | |
| 2408 Node* context = assembler.Parameter(Descriptor::kContext); | |
| 2409 | |
| 2410 assembler.Return( | |
| 2411 Generate(&assembler, function, slots, context, scope_type())); | |
| 2412 } | |
| 2413 | |
| 2414 // static | 2333 // static |
| 2415 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, | 2334 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, |
| 2416 compiler::Node* closure, | 2335 compiler::Node* closure, |
| 2417 compiler::Node* literal_index, | 2336 compiler::Node* literal_index, |
| 2418 compiler::Node* pattern, | 2337 compiler::Node* pattern, |
| 2419 compiler::Node* flags, | 2338 compiler::Node* flags, |
| 2420 compiler::Node* context) { | 2339 compiler::Node* context) { |
| 2421 typedef CodeStubAssembler::Label Label; | 2340 typedef CodeStubAssembler::Label Label; |
| 2422 typedef CodeStubAssembler::Variable Variable; | 2341 typedef CodeStubAssembler::Variable Variable; |
| 2423 typedef compiler::Node Node; | 2342 typedef compiler::Node Node; |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 } | 2882 } |
| 2964 | 2883 |
| 2965 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) | 2884 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
| 2966 : PlatformCodeStub(isolate) {} | 2885 : PlatformCodeStub(isolate) {} |
| 2967 | 2886 |
| 2968 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) | 2887 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) |
| 2969 : PlatformCodeStub(isolate) {} | 2888 : PlatformCodeStub(isolate) {} |
| 2970 | 2889 |
| 2971 } // namespace internal | 2890 } // namespace internal |
| 2972 } // namespace v8 | 2891 } // namespace v8 |
| OLD | NEW |