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

Side by Side Diff: src/runtime.cc

Issue 201042: Win64 - Allow returning two values from a runtime function. (Closed)
Patch Set: Fixed typo. Created 11 years, 3 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
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 4536 matching lines...) Expand 10 before | Expand all | Expand 10 after
4547 context->Lookup(name, flags, &index, &attributes); 4547 context->Lookup(name, flags, &index, &attributes);
4548 4548
4549 if (index < 0 && !holder.is_null()) { 4549 if (index < 0 && !holder.is_null()) {
4550 ASSERT(holder->IsJSObject()); 4550 ASSERT(holder->IsJSObject());
4551 return *holder; 4551 return *holder;
4552 } 4552 }
4553 4553
4554 // No intermediate context found. Use global object by default. 4554 // No intermediate context found. Use global object by default.
4555 return Top::context()->global(); 4555 return Top::context()->global();
4556 } 4556 }
4557 4557
William Hesse 2009/09/07 14:34:18 Why three blank lines?
Lasse Reichstein 2009/09/08 11:51:35 Indeed. Fixed.
4558 4558
4559
4559 // A mechanism to return pairs of Object*'s. This is somewhat 4560 // A mechanism to return pairs of Object*'s. This is somewhat
William Hesse 2009/09/07 14:34:18 Object pointers. pointers to Objects.
Lasse Reichstein 2009/09/08 11:51:35 Done.
4560 // compiler-dependent as it assumes that a 64-bit value (a long long) 4561 // compiler-dependent as it assumes that a 64-bit value (a long long)
4561 // is returned via two registers (edx:eax on ia32). Both the ia32 and 4562 // is returned via two registers (edx:eax on ia32). Both the ia32 and
4562 // arm platform support this; it is mostly an issue of "coaxing" the 4563 // arm platform support this; it is mostly an issue of "coaxing" the
William Hesse 2009/09/07 14:34:18 Change this whole comment. Say that it works on o
Lasse Reichstein 2009/09/08 11:51:35 Done.
4563 // compiler to do the right thing. 4564 // compiler to do the right thing.
4564 // 4565 //
4565 // TODO(1236026): This is a non-portable hack that should be removed. 4566 // TODO(1236026): This is a non-portable hack that should be removed.
4566 #ifdef V8_HOST_ARCH_64_BIT 4567 #ifdef V8_HOST_ARCH_64_BIT
4567 // Tested with GCC, not with MSVC. 4568 // Tested with GCC, not with MSVC.
4569 // Doesn't work in MSVC without changing call sequence.
4570 // A structure used to return pairs of Object*'s.
4568 struct ObjectPair { 4571 struct ObjectPair {
4569 Object* x; 4572 Object* x;
4570 Object* y; 4573 Object* y;
4571 }; 4574 };
4575
4572 static inline ObjectPair MakePair(Object* x, Object* y) { 4576 static inline ObjectPair MakePair(Object* x, Object* y) {
4573 ObjectPair result = {x, y}; 4577 ObjectPair result = {x, y};
4574 return result; // Pointers x and y returned in rax and rdx, in AMD-x64-abi. 4578 return result; // Pointers x and y returned in rax and rdx, in AMD-x64-abi.
4575 } 4579 }
4576 #else 4580 #else
4577 typedef uint64_t ObjectPair; 4581 typedef uint64_t ObjectPair;
4578 static inline ObjectPair MakePair(Object* x, Object* y) { 4582 static inline ObjectPair MakePair(Object* x, Object* y) {
4579 return reinterpret_cast<uint32_t>(x) | 4583 return reinterpret_cast<uint32_t>(x) |
4580 (reinterpret_cast<ObjectPair>(y) << 32); 4584 (reinterpret_cast<ObjectPair>(y) << 32);
4581 } 4585 }
4582 #endif 4586 #endif
4583 4587
4584 4588
4585
4586
4587 static inline Object* Unhole(Object* x, PropertyAttributes attributes) { 4589 static inline Object* Unhole(Object* x, PropertyAttributes attributes) {
4588 ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0); 4590 ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
4589 USE(attributes); 4591 USE(attributes);
4590 return x->IsTheHole() ? Heap::undefined_value() : x; 4592 return x->IsTheHole() ? Heap::undefined_value() : x;
4591 } 4593 }
4592 4594
4593 4595
4594 static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) { 4596 static JSObject* ComputeReceiverForNonGlobal(JSObject* holder) {
4595 ASSERT(!holder->IsGlobalObject()); 4597 ASSERT(!holder->IsGlobalObject());
4596 Context* top = Top::context(); 4598 Context* top = Top::context();
(...skipping 2994 matching lines...) Expand 10 before | Expand all | Expand 10 after
7591 7593
7592 7594
7593 #ifdef DEBUG 7595 #ifdef DEBUG
7594 // ListNatives is ONLY used by the fuzz-natives.js in debug mode 7596 // ListNatives is ONLY used by the fuzz-natives.js in debug mode
7595 // Exclude the code in release mode. 7597 // Exclude the code in release mode.
7596 static Object* Runtime_ListNatives(Arguments args) { 7598 static Object* Runtime_ListNatives(Arguments args) {
7597 ASSERT(args.length() == 0); 7599 ASSERT(args.length() == 0);
7598 HandleScope scope; 7600 HandleScope scope;
7599 Handle<JSArray> result = Factory::NewJSArray(0); 7601 Handle<JSArray> result = Factory::NewJSArray(0);
7600 int index = 0; 7602 int index = 0;
7601 #define ADD_ENTRY(Name, argc) \ 7603 #define ADD_ENTRY(Name, argc, ressize) \
7602 { \ 7604 { \
7603 HandleScope inner; \ 7605 HandleScope inner; \
7604 Handle<String> name = \ 7606 Handle<String> name = \
7605 Factory::NewStringFromAscii(Vector<const char>(#Name, strlen(#Name))); \ 7607 Factory::NewStringFromAscii(Vector<const char>(#Name, strlen(#Name))); \
7606 Handle<JSArray> pair = Factory::NewJSArray(0); \ 7608 Handle<JSArray> pair = Factory::NewJSArray(0); \
7607 SetElement(pair, 0, name); \ 7609 SetElement(pair, 0, name); \
7608 SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \ 7610 SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \
7609 SetElement(result, index++, pair); \ 7611 SetElement(result, index++, pair); \
7610 } 7612 }
7611 RUNTIME_FUNCTION_LIST(ADD_ENTRY) 7613 RUNTIME_FUNCTION_LIST(ADD_ENTRY)
(...skipping 15 matching lines...) Expand all
7627 7629
7628 static Object* Runtime_IS_VAR(Arguments args) { 7630 static Object* Runtime_IS_VAR(Arguments args) {
7629 UNREACHABLE(); // implemented as macro in the parser 7631 UNREACHABLE(); // implemented as macro in the parser
7630 return NULL; 7632 return NULL;
7631 } 7633 }
7632 7634
7633 7635
7634 // ---------------------------------------------------------------------------- 7636 // ----------------------------------------------------------------------------
7635 // Implementation of Runtime 7637 // Implementation of Runtime
7636 7638
7637 #define F(name, nargs) \ 7639 #define F(name, nargs, ressize) \
7638 { #name, "RuntimeStub_" #name, FUNCTION_ADDR(Runtime_##name), nargs, \ 7640 { #name, "RuntimeStub_" #name, FUNCTION_ADDR(Runtime_##name), nargs, \
7639 static_cast<int>(Runtime::k##name) }, 7641 static_cast<int>(Runtime::k##name), ressize },
7640 7642
7641 static Runtime::Function Runtime_functions[] = { 7643 static Runtime::Function Runtime_functions[] = {
7642 RUNTIME_FUNCTION_LIST(F) 7644 RUNTIME_FUNCTION_LIST(F)
7643 { NULL, NULL, NULL, 0, -1 } 7645 { NULL, NULL, NULL, 0, -1, 0 }
7644 }; 7646 };
7645 7647
7646 #undef F 7648 #undef F
7647 7649
7648 7650
7649 Runtime::Function* Runtime::FunctionForId(FunctionId fid) { 7651 Runtime::Function* Runtime::FunctionForId(FunctionId fid) {
7650 ASSERT(0 <= fid && fid < kNofFunctions); 7652 ASSERT(0 <= fid && fid < kNofFunctions);
7651 return &Runtime_functions[fid]; 7653 return &Runtime_functions[fid];
7652 } 7654 }
7653 7655
(...skipping 17 matching lines...) Expand all
7671 } else { 7673 } else {
7672 // Handle last resort GC and make sure to allow future allocations 7674 // Handle last resort GC and make sure to allow future allocations
7673 // to grow the heap without causing GCs (if possible). 7675 // to grow the heap without causing GCs (if possible).
7674 Counters::gc_last_resort_from_js.Increment(); 7676 Counters::gc_last_resort_from_js.Increment();
7675 Heap::CollectAllGarbage(false); 7677 Heap::CollectAllGarbage(false);
7676 } 7678 }
7677 } 7679 }
7678 7680
7679 7681
7680 } } // namespace v8::internal 7682 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698