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

Side by Side Diff: src/runtime.cc

Issue 157543002: A64: Synchronize with r18581. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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/runtime.h ('k') | src/runtime.js » ('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 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after
2656 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); 2656 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift);
2657 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); 2657 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
2658 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); 2658 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
2659 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); 2659 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
2660 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); 2660 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat);
2661 2661
2662 return *holder; 2662 return *holder;
2663 } 2663 }
2664 2664
2665 2665
2666 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsCallable) {
2667 SealHandleScope shs(isolate);
2668 ASSERT(args.length() == 1);
2669 CONVERT_ARG_CHECKED(Object, obj, 0);
2670 return isolate->heap()->ToBoolean(obj->IsCallable());
2671 }
2672
2673
2674 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { 2666 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) {
2675 SealHandleScope shs(isolate); 2667 SealHandleScope shs(isolate);
2676 ASSERT(args.length() == 1); 2668 ASSERT(args.length() == 1);
2677 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2669 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2678 if (!callable->IsJSFunction()) { 2670 if (!callable->IsJSFunction()) {
2679 HandleScope scope(isolate); 2671 HandleScope scope(isolate);
2680 bool threw = false; 2672 bool threw = false;
2681 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2673 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2682 isolate, Handle<JSReceiver>(callable), &threw); 2674 isolate, Handle<JSReceiver>(callable), &threw);
2683 if (threw) return Failure::Exception(); 2675 if (threw) return Failure::Exception();
(...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after
5737 JSObject::cast(proto)->map()->is_hidden_prototype()) { 5729 JSObject::cast(proto)->map()->is_hidden_prototype()) {
5738 count++; 5730 count++;
5739 proto = JSObject::cast(proto)->GetPrototype(); 5731 proto = JSObject::cast(proto)->GetPrototype();
5740 } 5732 }
5741 return count; 5733 return count;
5742 } 5734 }
5743 5735
5744 5736
5745 // Return the names of the local named properties. 5737 // Return the names of the local named properties.
5746 // args[0]: object 5738 // args[0]: object
5739 // args[1]: PropertyAttributes as int
5747 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { 5740 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) {
5748 HandleScope scope(isolate); 5741 HandleScope scope(isolate);
5749 ASSERT(args.length() == 2); 5742 ASSERT(args.length() == 2);
5750 if (!args[0]->IsJSObject()) { 5743 if (!args[0]->IsJSObject()) {
5751 return isolate->heap()->undefined_value(); 5744 return isolate->heap()->undefined_value();
5752 } 5745 }
5753 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 5746 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
5754 CONVERT_BOOLEAN_ARG_CHECKED(include_symbols, 1); 5747 CONVERT_SMI_ARG_CHECKED(filter_value, 1);
5755 PropertyAttributes filter = include_symbols ? NONE : SYMBOLIC; 5748 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value);
5756 5749
5757 // Skip the global proxy as it has no properties and always delegates to the 5750 // Skip the global proxy as it has no properties and always delegates to the
5758 // real global object. 5751 // real global object.
5759 if (obj->IsJSGlobalProxy()) { 5752 if (obj->IsJSGlobalProxy()) {
5760 // Only collect names if access is permitted. 5753 // Only collect names if access is permitted.
5761 if (obj->IsAccessCheckNeeded() && 5754 if (obj->IsAccessCheckNeeded() &&
5762 !isolate->MayNamedAccess(*obj, 5755 !isolate->MayNamedAccess(*obj,
5763 isolate->heap()->undefined_value(), 5756 isolate->heap()->undefined_value(),
5764 v8::ACCESS_KEYS)) { 5757 v8::ACCESS_KEYS)) {
5765 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS); 5758 isolate->ReportFailedAccessCheck(*obj, v8::ACCESS_KEYS);
(...skipping 28 matching lines...) Expand all
5794 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5787 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5795 } 5788 }
5796 } 5789 }
5797 5790
5798 // Allocate an array with storage for all the property names. 5791 // Allocate an array with storage for all the property names.
5799 Handle<FixedArray> names = 5792 Handle<FixedArray> names =
5800 isolate->factory()->NewFixedArray(total_property_count); 5793 isolate->factory()->NewFixedArray(total_property_count);
5801 5794
5802 // Get the property names. 5795 // Get the property names.
5803 jsproto = obj; 5796 jsproto = obj;
5804 int proto_with_hidden_properties = 0;
5805 int next_copy_index = 0; 5797 int next_copy_index = 0;
5798 int hidden_strings = 0;
5806 for (int i = 0; i < length; i++) { 5799 for (int i = 0; i < length; i++) {
5807 jsproto->GetLocalPropertyNames(*names, next_copy_index, filter); 5800 jsproto->GetLocalPropertyNames(*names, next_copy_index, filter);
5801 if (i > 0) {
5802 // Names from hidden prototypes may already have been added
5803 // for inherited function template instances. Count the duplicates
5804 // and stub them out; the final copy pass at the end ignores holes.
5805 for (int j = next_copy_index;
5806 j < next_copy_index + local_property_count[i];
5807 j++) {
5808 Object* name_from_hidden_proto = names->get(j);
5809 for (int k = 0; k < next_copy_index; k++) {
5810 if (names->get(k) != isolate->heap()->hidden_string()) {
5811 Object* name = names->get(k);
5812 if (name_from_hidden_proto == name) {
5813 names->set(j, isolate->heap()->hidden_string());
5814 hidden_strings++;
5815 break;
5816 }
5817 }
5818 }
5819 }
5820 }
5808 next_copy_index += local_property_count[i]; 5821 next_copy_index += local_property_count[i];
5809 if (jsproto->HasHiddenProperties()) { 5822 if (jsproto->HasHiddenProperties()) {
5810 proto_with_hidden_properties++; 5823 hidden_strings++;
5811 } 5824 }
5812 if (i < length - 1) { 5825 if (i < length - 1) {
5813 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); 5826 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype()));
5814 } 5827 }
5815 } 5828 }
5816 5829
5817 // Filter out name of hidden properties object. 5830 // Filter out name of hidden properties object and
5818 if (proto_with_hidden_properties > 0) { 5831 // hidden prototype duplicates.
5832 if (hidden_strings > 0) {
5819 Handle<FixedArray> old_names = names; 5833 Handle<FixedArray> old_names = names;
5820 names = isolate->factory()->NewFixedArray( 5834 names = isolate->factory()->NewFixedArray(
5821 names->length() - proto_with_hidden_properties); 5835 names->length() - hidden_strings);
5822 int dest_pos = 0; 5836 int dest_pos = 0;
5823 for (int i = 0; i < total_property_count; i++) { 5837 for (int i = 0; i < total_property_count; i++) {
5824 Object* name = old_names->get(i); 5838 Object* name = old_names->get(i);
5825 if (name == isolate->heap()->hidden_string()) { 5839 if (name == isolate->heap()->hidden_string()) {
5840 hidden_strings--;
5826 continue; 5841 continue;
5827 } 5842 }
5828 names->set(dest_pos++, name); 5843 names->set(dest_pos++, name);
5829 } 5844 }
5845 ASSERT_EQ(0, hidden_strings);
5830 } 5846 }
5831 5847
5832 return *isolate->factory()->NewJSArrayWithElements(names); 5848 return *isolate->factory()->NewJSArrayWithElements(names);
5833 } 5849 }
5834 5850
5835 5851
5836 // Return the names of the local indexed properties. 5852 // Return the names of the local indexed properties.
5837 // args[0]: object 5853 // args[0]: object
5838 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) { 5854 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) {
5839 HandleScope scope(isolate); 5855 HandleScope scope(isolate);
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
6495 // NOTE: This assumes that the upper/lower case of an ASCII 6511 // NOTE: This assumes that the upper/lower case of an ASCII
6496 // character is also ASCII. This is currently the case, but it 6512 // character is also ASCII. This is currently the case, but it
6497 // might break in the future if we implement more context and locale 6513 // might break in the future if we implement more context and locale
6498 // dependent upper/lower conversions. 6514 // dependent upper/lower conversions.
6499 if (s->IsSeqOneByteString()) { 6515 if (s->IsSeqOneByteString()) {
6500 Object* o; 6516 Object* o;
6501 { MaybeObject* maybe_o = isolate->heap()->AllocateRawOneByteString(length); 6517 { MaybeObject* maybe_o = isolate->heap()->AllocateRawOneByteString(length);
6502 if (!maybe_o->ToObject(&o)) return maybe_o; 6518 if (!maybe_o->ToObject(&o)) return maybe_o;
6503 } 6519 }
6504 SeqOneByteString* result = SeqOneByteString::cast(o); 6520 SeqOneByteString* result = SeqOneByteString::cast(o);
6505 bool has_changed_character; 6521 bool has_changed_character = false;
6506 bool is_ascii = FastAsciiConvert<Converter>( 6522 bool is_ascii = FastAsciiConvert<Converter>(
6507 reinterpret_cast<char*>(result->GetChars()), 6523 reinterpret_cast<char*>(result->GetChars()),
6508 reinterpret_cast<char*>(SeqOneByteString::cast(s)->GetChars()), 6524 reinterpret_cast<char*>(SeqOneByteString::cast(s)->GetChars()),
6509 length, 6525 length,
6510 &has_changed_character); 6526 &has_changed_character);
6511 // If not ASCII, we discard the result and take the 2 byte path. 6527 // If not ASCII, we discard the result and take the 2 byte path.
6512 if (is_ascii) { 6528 if (is_ascii) {
6513 return has_changed_character ? result : s; 6529 return has_changed_character ? result : s;
6514 } 6530 }
6515 } 6531 }
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after
7650 : StringCharacterStreamCompare(isolate->runtime_state(), x, y); 7666 : StringCharacterStreamCompare(isolate->runtime_state(), x, y);
7651 } 7667 }
7652 7668
7653 7669
7654 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) { 7670 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_acos) {
7655 SealHandleScope shs(isolate); 7671 SealHandleScope shs(isolate);
7656 ASSERT(args.length() == 1); 7672 ASSERT(args.length() == 1);
7657 isolate->counters()->math_acos()->Increment(); 7673 isolate->counters()->math_acos()->Increment();
7658 7674
7659 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7675 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7660 return isolate->heap()->AllocateHeapNumber(acos(x)); 7676 return isolate->heap()->AllocateHeapNumber(std::acos(x));
7661 } 7677 }
7662 7678
7663 7679
7664 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) { 7680 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_asin) {
7665 SealHandleScope shs(isolate); 7681 SealHandleScope shs(isolate);
7666 ASSERT(args.length() == 1); 7682 ASSERT(args.length() == 1);
7667 isolate->counters()->math_asin()->Increment(); 7683 isolate->counters()->math_asin()->Increment();
7668 7684
7669 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7685 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7670 return isolate->heap()->AllocateHeapNumber(asin(x)); 7686 return isolate->heap()->AllocateHeapNumber(std::asin(x));
7671 } 7687 }
7672 7688
7673 7689
7674 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) { 7690 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan) {
7675 SealHandleScope shs(isolate); 7691 SealHandleScope shs(isolate);
7676 ASSERT(args.length() == 1); 7692 ASSERT(args.length() == 1);
7677 isolate->counters()->math_atan()->Increment(); 7693 isolate->counters()->math_atan()->Increment();
7678 7694
7679 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7695 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7680 return isolate->heap()->AllocateHeapNumber(atan(x)); 7696 return isolate->heap()->AllocateHeapNumber(std::atan(x));
7681 } 7697 }
7682 7698
7683 7699
7684 static const double kPiDividedBy4 = 0.78539816339744830962; 7700 static const double kPiDividedBy4 = 0.78539816339744830962;
7685 7701
7686 7702
7687 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) { 7703 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_atan2) {
7688 SealHandleScope shs(isolate); 7704 SealHandleScope shs(isolate);
7689 ASSERT(args.length() == 2); 7705 ASSERT(args.length() == 2);
7690 isolate->counters()->math_atan2()->Increment(); 7706 isolate->counters()->math_atan2()->Increment();
7691 7707
7692 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7708 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7693 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7709 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7694 double result; 7710 double result;
7695 if (std::isinf(x) && std::isinf(y)) { 7711 if (std::isinf(x) && std::isinf(y)) {
7696 // Make sure that the result in case of two infinite arguments 7712 // Make sure that the result in case of two infinite arguments
7697 // is a multiple of Pi / 4. The sign of the result is determined 7713 // is a multiple of Pi / 4. The sign of the result is determined
7698 // by the first argument (x) and the sign of the second argument 7714 // by the first argument (x) and the sign of the second argument
7699 // determines the multiplier: one or three. 7715 // determines the multiplier: one or three.
7700 int multiplier = (x < 0) ? -1 : 1; 7716 int multiplier = (x < 0) ? -1 : 1;
7701 if (y < 0) multiplier *= 3; 7717 if (y < 0) multiplier *= 3;
7702 result = multiplier * kPiDividedBy4; 7718 result = multiplier * kPiDividedBy4;
7703 } else { 7719 } else {
7704 result = atan2(x, y); 7720 result = std::atan2(x, y);
7705 } 7721 }
7706 return isolate->heap()->AllocateHeapNumber(result); 7722 return isolate->heap()->AllocateHeapNumber(result);
7707 } 7723 }
7708 7724
7709 7725
7710 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) { 7726 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_exp) {
7711 SealHandleScope shs(isolate); 7727 SealHandleScope shs(isolate);
7712 ASSERT(args.length() == 1); 7728 ASSERT(args.length() == 1);
7713 isolate->counters()->math_exp()->Increment(); 7729 isolate->counters()->math_exp()->Increment();
7714 7730
7715 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7731 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7716 lazily_initialize_fast_exp(); 7732 lazily_initialize_fast_exp();
7717 return isolate->heap()->NumberFromDouble(fast_exp(x)); 7733 return isolate->heap()->NumberFromDouble(fast_exp(x));
7718 } 7734 }
7719 7735
7720 7736
7721 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) { 7737 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_floor) {
7722 SealHandleScope shs(isolate); 7738 SealHandleScope shs(isolate);
7723 ASSERT(args.length() == 1); 7739 ASSERT(args.length() == 1);
7724 isolate->counters()->math_floor()->Increment(); 7740 isolate->counters()->math_floor()->Increment();
7725 7741
7726 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7742 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7727 return isolate->heap()->NumberFromDouble(floor(x)); 7743 return isolate->heap()->NumberFromDouble(std::floor(x));
7728 } 7744 }
7729 7745
7730 7746
7731 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) { 7747 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_log) {
7732 SealHandleScope shs(isolate); 7748 SealHandleScope shs(isolate);
7733 ASSERT(args.length() == 1); 7749 ASSERT(args.length() == 1);
7734 isolate->counters()->math_log()->Increment(); 7750 isolate->counters()->math_log()->Increment();
7735 7751
7736 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7752 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7737 return isolate->heap()->AllocateHeapNumber(log(x)); 7753 return isolate->heap()->AllocateHeapNumber(std::log(x));
7738 } 7754 }
7739 7755
7740 7756
7741 // Slow version of Math.pow. We check for fast paths for special cases. 7757 // Slow version of Math.pow. We check for fast paths for special cases.
7742 // Used if SSE2/VFP3 is not available. 7758 // Used if SSE2/VFP3 is not available.
7743 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) { 7759 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_pow) {
7744 SealHandleScope shs(isolate); 7760 SealHandleScope shs(isolate);
7745 ASSERT(args.length() == 2); 7761 ASSERT(args.length() == 2);
7746 isolate->counters()->math_pow()->Increment(); 7762 isolate->counters()->math_pow()->Increment();
7747 7763
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
7812 7828
7813 // If the magnitude is big enough, there's no place for fraction part. If we 7829 // If the magnitude is big enough, there's no place for fraction part. If we
7814 // try to add 0.5 to this number, 1.0 will be added instead. 7830 // try to add 0.5 to this number, 1.0 will be added instead.
7815 if (exponent >= 52) { 7831 if (exponent >= 52) {
7816 return number; 7832 return number;
7817 } 7833 }
7818 7834
7819 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); 7835 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
7820 7836
7821 // Do not call NumberFromDouble() to avoid extra checks. 7837 // Do not call NumberFromDouble() to avoid extra checks.
7822 return isolate->heap()->AllocateHeapNumber(floor(value + 0.5)); 7838 return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5));
7823 } 7839 }
7824 7840
7825 7841
7826 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) { 7842 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math_sqrt) {
7827 SealHandleScope shs(isolate); 7843 SealHandleScope shs(isolate);
7828 ASSERT(args.length() == 1); 7844 ASSERT(args.length() == 1);
7829 isolate->counters()->math_sqrt()->Increment(); 7845 isolate->counters()->math_sqrt()->Increment();
7830 7846
7831 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7847 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7832 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); 7848 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x));
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
9147 JSFunction* context_extension_function = 9163 JSFunction* context_extension_function =
9148 top->native_context()->context_extension_function(); 9164 top->native_context()->context_extension_function();
9149 // If the holder isn't a context extension object, we just return it 9165 // If the holder isn't a context extension object, we just return it
9150 // as the receiver. This allows arguments objects to be used as 9166 // as the receiver. This allows arguments objects to be used as
9151 // receivers, but only if they are put in the context scope chain 9167 // receivers, but only if they are put in the context scope chain
9152 // explicitly via a with-statement. 9168 // explicitly via a with-statement.
9153 Object* constructor = holder->map()->constructor(); 9169 Object* constructor = holder->map()->constructor();
9154 if (constructor != context_extension_function) return holder; 9170 if (constructor != context_extension_function) return holder;
9155 // Fall back to using the global object as the implicit receiver if 9171 // Fall back to using the global object as the implicit receiver if
9156 // the property turns out to be a local variable allocated in a 9172 // the property turns out to be a local variable allocated in a
9157 // context extension object - introduced via eval. Implicit global 9173 // context extension object - introduced via eval.
9158 // receivers are indicated with the hole value. 9174 return isolate->heap()->undefined_value();
9159 return isolate->heap()->the_hole_value();
9160 } 9175 }
9161 9176
9162 9177
9163 static ObjectPair LoadContextSlotHelper(Arguments args, 9178 static ObjectPair LoadContextSlotHelper(Arguments args,
9164 Isolate* isolate, 9179 Isolate* isolate,
9165 bool throw_error) { 9180 bool throw_error) {
9166 HandleScope scope(isolate); 9181 HandleScope scope(isolate);
9167 ASSERT_EQ(2, args.length()); 9182 ASSERT_EQ(2, args.length());
9168 9183
9169 if (!args[0]->IsContext() || !args[1]->IsString()) { 9184 if (!args[0]->IsContext() || !args[1]->IsString()) {
(...skipping 13 matching lines...) Expand all
9183 &binding_flags); 9198 &binding_flags);
9184 if (isolate->has_pending_exception()) { 9199 if (isolate->has_pending_exception()) {
9185 return MakePair(Failure::Exception(), NULL); 9200 return MakePair(Failure::Exception(), NULL);
9186 } 9201 }
9187 9202
9188 // If the index is non-negative, the slot has been found in a context. 9203 // If the index is non-negative, the slot has been found in a context.
9189 if (index >= 0) { 9204 if (index >= 0) {
9190 ASSERT(holder->IsContext()); 9205 ASSERT(holder->IsContext());
9191 // If the "property" we were looking for is a local variable, the 9206 // If the "property" we were looking for is a local variable, the
9192 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. 9207 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3.
9193 // 9208 Handle<Object> receiver = isolate->factory()->undefined_value();
9194 // Use the hole as the receiver to signal that the receiver is implicit
9195 // and that the global receiver should be used (as distinguished from an
9196 // explicit receiver that happens to be a global object).
9197 Handle<Object> receiver = isolate->factory()->the_hole_value();
9198 Object* value = Context::cast(*holder)->get(index); 9209 Object* value = Context::cast(*holder)->get(index);
9199 // Check for uninitialized bindings. 9210 // Check for uninitialized bindings.
9200 switch (binding_flags) { 9211 switch (binding_flags) {
9201 case MUTABLE_CHECK_INITIALIZED: 9212 case MUTABLE_CHECK_INITIALIZED:
9202 case IMMUTABLE_CHECK_INITIALIZED_HARMONY: 9213 case IMMUTABLE_CHECK_INITIALIZED_HARMONY:
9203 if (value->IsTheHole()) { 9214 if (value->IsTheHole()) {
9204 Handle<Object> reference_error = 9215 Handle<Object> reference_error =
9205 isolate->factory()->NewReferenceError("not_defined", 9216 isolate->factory()->NewReferenceError("not_defined",
9206 HandleVector(&name, 1)); 9217 HandleVector(&name, 1));
9207 return MakePair(isolate->Throw(*reference_error), NULL); 9218 return MakePair(isolate->Throw(*reference_error), NULL);
(...skipping 14 matching lines...) Expand all
9222 9233
9223 // Otherwise, if the slot was found the holder is a context extension 9234 // Otherwise, if the slot was found the holder is a context extension
9224 // object, subject of a with, or a global object. We read the named 9235 // object, subject of a with, or a global object. We read the named
9225 // property from it. 9236 // property from it.
9226 if (!holder.is_null()) { 9237 if (!holder.is_null()) {
9227 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder); 9238 Handle<JSReceiver> object = Handle<JSReceiver>::cast(holder);
9228 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name)); 9239 ASSERT(object->IsJSProxy() || JSReceiver::HasProperty(object, name));
9229 // GetProperty below can cause GC. 9240 // GetProperty below can cause GC.
9230 Handle<Object> receiver_handle( 9241 Handle<Object> receiver_handle(
9231 object->IsGlobalObject() 9242 object->IsGlobalObject()
9232 ? GlobalObject::cast(*object)->global_receiver() 9243 ? Object::cast(isolate->heap()->undefined_value())
9233 : object->IsJSProxy() ? static_cast<Object*>(*object) 9244 : object->IsJSProxy() ? static_cast<Object*>(*object)
9234 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), 9245 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)),
9235 isolate); 9246 isolate);
9236 9247
9237 // No need to unhole the value here. This is taken care of by the 9248 // No need to unhole the value here. This is taken care of by the
9238 // GetProperty function. 9249 // GetProperty function.
9239 MaybeObject* value = object->GetProperty(*name); 9250 MaybeObject* value = object->GetProperty(*name);
9240 return MakePair(value, *receiver_handle); 9251 return MakePair(value, *receiver_handle);
9241 } 9252 }
9242 9253
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
9527 9538
9528 9539
9529 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { 9540 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) {
9530 SealHandleScope shs(isolate); 9541 SealHandleScope shs(isolate);
9531 ASSERT(args.length() == 0); 9542 ASSERT(args.length() == 0);
9532 9543
9533 // According to ECMA-262, section 15.9.1, page 117, the precision of 9544 // According to ECMA-262, section 15.9.1, page 117, the precision of
9534 // the number in a Date object representing a particular instant in 9545 // the number in a Date object representing a particular instant in
9535 // time is milliseconds. Therefore, we floor the result of getting 9546 // time is milliseconds. Therefore, we floor the result of getting
9536 // the OS time. 9547 // the OS time.
9537 double millis = floor(OS::TimeCurrentMillis()); 9548 double millis = std::floor(OS::TimeCurrentMillis());
9538 return isolate->heap()->NumberFromDouble(millis); 9549 return isolate->heap()->NumberFromDouble(millis);
9539 } 9550 }
9540 9551
9541 9552
9542 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { 9553 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
9543 HandleScope scope(isolate); 9554 HandleScope scope(isolate);
9544 ASSERT(args.length() == 2); 9555 ASSERT(args.length() == 2);
9545 9556
9546 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); 9557 CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
9547 FlattenString(str); 9558 FlattenString(str);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
9721 9732
9722 Handle<Object> callee = args.at<Object>(0); 9733 Handle<Object> callee = args.at<Object>(0);
9723 9734
9724 // If "eval" didn't refer to the original GlobalEval, it's not a 9735 // If "eval" didn't refer to the original GlobalEval, it's not a
9725 // direct call to eval. 9736 // direct call to eval.
9726 // (And even if it is, but the first argument isn't a string, just let 9737 // (And even if it is, but the first argument isn't a string, just let
9727 // execution default to an indirect call to eval, which will also return 9738 // execution default to an indirect call to eval, which will also return
9728 // the first argument without doing anything). 9739 // the first argument without doing anything).
9729 if (*callee != isolate->native_context()->global_eval_fun() || 9740 if (*callee != isolate->native_context()->global_eval_fun() ||
9730 !args[1]->IsString()) { 9741 !args[1]->IsString()) {
9731 return MakePair(*callee, isolate->heap()->the_hole_value()); 9742 return MakePair(*callee, isolate->heap()->undefined_value());
9732 } 9743 }
9733 9744
9734 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9745 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9735 ASSERT(args[4]->IsSmi()); 9746 ASSERT(args[4]->IsSmi());
9736 return CompileGlobalEval(isolate, 9747 return CompileGlobalEval(isolate,
9737 args.at<String>(1), 9748 args.at<String>(1),
9738 args.at<Object>(2), 9749 args.at<Object>(2),
9739 language_mode, 9750 language_mode,
9740 args.smi_at(4)); 9751 args.smi_at(4));
9741 } 9752 }
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
11313 if (!receiver->IsJSObject() && 11324 if (!receiver->IsJSObject() &&
11314 shared->is_classic_mode() && 11325 shared->is_classic_mode() &&
11315 !function->IsBuiltin()) { 11326 !function->IsBuiltin()) {
11316 // If the receiver is not a JSObject and the function is not a 11327 // If the receiver is not a JSObject and the function is not a
11317 // builtin or strict-mode we have hit an optimization where a 11328 // builtin or strict-mode we have hit an optimization where a
11318 // value object is not converted into a wrapped JS objects. To 11329 // value object is not converted into a wrapped JS objects. To
11319 // hide this optimization from the debugger, we wrap the receiver 11330 // hide this optimization from the debugger, we wrap the receiver
11320 // by creating correct wrapper object based on the calling frame's 11331 // by creating correct wrapper object based on the calling frame's
11321 // native context. 11332 // native context.
11322 it.Advance(); 11333 it.Advance();
11323 Handle<Context> calling_frames_native_context( 11334 if (receiver->IsUndefined()) {
11324 Context::cast(Context::cast(it.frame()->context())->native_context())); 11335 Context* context = function->context();
11325 ASSERT(!receiver->IsUndefined() && !receiver->IsNull()); 11336 receiver = handle(context->global_object()->global_receiver());
11326 receiver = 11337 } else {
11327 isolate->factory()->ToObject(receiver, calling_frames_native_context); 11338 ASSERT(!receiver->IsNull());
11339 Context* context = Context::cast(it.frame()->context());
11340 Handle<Context> native_context(Context::cast(context->native_context()));
11341 receiver = isolate->factory()->ToObject(receiver, native_context);
11342 }
11328 } 11343 }
11329 details->set(kFrameDetailsReceiverIndex, *receiver); 11344 details->set(kFrameDetailsReceiverIndex, *receiver);
11330 11345
11331 ASSERT_EQ(details_size, details_index); 11346 ASSERT_EQ(details_size, details_index);
11332 return *isolate->factory()->NewJSArrayWithElements(details); 11347 return *isolate->factory()->NewJSArrayWithElements(details);
11333 } 11348 }
11334 11349
11335 11350
11336 // Create a plain JSObject which materializes the local scope for the specified 11351 // Create a plain JSObject which materializes the local scope for the specified
11337 // frame. 11352 // frame.
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after
14868 // Handle last resort GC and make sure to allow future allocations 14883 // Handle last resort GC and make sure to allow future allocations
14869 // to grow the heap without causing GCs (if possible). 14884 // to grow the heap without causing GCs (if possible).
14870 isolate->counters()->gc_last_resort_from_js()->Increment(); 14885 isolate->counters()->gc_last_resort_from_js()->Increment();
14871 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14886 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14872 "Runtime::PerformGC"); 14887 "Runtime::PerformGC");
14873 } 14888 }
14874 } 14889 }
14875 14890
14876 14891
14877 } } // namespace v8::internal 14892 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698